Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.brendan/crash62.C

raw
1 // { dg-do assemble }
2 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
3 // GROUPS passed old-abort
4 #include <iostream>
5
6 void
7 fubar(std::ostream* out, const char* s)
8 {
9 (*out) << s << std::endl;
10 return;
11 }
12
13 int
14 main()
15 {
16 // Declare a ref and a pointer to the same ostream.
17 //
18 std::ostream* out = &std::cerr;
19 std::ostream& die = std::cerr;
20
21 // Valid call to fubar.
22 //
23 fubar(out, "First line.");
24
25 // Invalid call to fubar. (1st arg is an ostream&. fubar expects
26 // ostream*.)This should be a syntax error, but g++ does not catch it.
27 // Call to this function results in a bus error in fubar when the 1st
28 // arg is dereferenced.
29 //
30 fubar(die, "Second line.");// { dg-error "" } cannot convert .die.*
31
32 return 1;
33 }