| 1 |
// { dg-do run } |
| 2 |
// { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } } |
| 3 |
// GROUPS passed conversions |
| 4 |
#include <cstdio> |
| 5 |
#include <cstdlib> |
| 6 |
#include <cstring> |
| 7 |
#include <iostream> |
| 8 |
#include <fstream> |
| 9 |
|
| 10 |
class cvec { |
| 11 |
public: |
| 12 |
~cvec(){ delete s; } |
| 13 |
cvec(const char*x) { s = new char[std::strlen(x)+1]; std::strcpy(s, x); } |
| 14 |
cvec(const cvec& c) { s = new char[std::strlen(c.s)+1]; std::strcpy(s, c.s); } |
| 15 |
operator const char*() { return s; } |
| 16 |
private: |
| 17 |
char *s; |
| 18 |
}; |
| 19 |
|
| 20 |
cvec |
| 21 |
B(const char* a) |
| 22 |
{ |
| 23 |
return a; |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
A(const char* s) |
| 28 |
{ |
| 29 |
// s still ok here |
| 30 |
std::ifstream inf(s); |
| 31 |
if (std::strncmp ("aaa", s, 3)) |
| 32 |
{ |
| 33 |
std::printf ("FAIL\n"); |
| 34 |
std::exit (1); |
| 35 |
} |
| 36 |
else |
| 37 |
std::printf ("PASS\n"); |
| 38 |
} |
| 39 |
|
| 40 |
int main() |
| 41 |
{ |
| 42 |
A(B("aaa")); |
| 43 |
} |