OSDN Git Service

2001-04-06 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.law / cvt2.C
1 // GROUPS passed conversions
2 #include <cstdio>
3 #include <cstdlib>
4 #include <cstring>
5 #include <iostream>
6 #include <fstream>
7
8 class cvec {
9 public:
10         ~cvec(){ delete s; }
11         cvec(const char*x) { s = new char[strlen(x)+1]; strcpy(s, x); }
12         cvec(const cvec& c) { s = new char[strlen(c.s)+1]; strcpy(s, c.s); }
13         operator const char*() { return s; }
14 private:
15         char *s;
16 };
17
18 cvec
19 B(const char* a)
20 {
21         return a;
22 }
23
24 void
25 A(const char* s)
26 {
27         // s still ok here
28         std::ifstream inf(s);
29         if (std::strncmp ("aaa", s, 3))
30           {
31             std::printf ("FAIL\n");
32             std::exit (1);
33           }
34         else
35           std::printf ("PASS\n");
36 }
37
38 int main()
39 {
40         A(B("aaa"));
41 }