This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Questionable 1.1 C++ parsing


| // Build don't link:
| // Based on a test case by Phil Blecker <tmwg@inxservices.com>
| 
| int foo(int);
| int bar() {
|   int baz(int(foo(bar())));
|   int foo = baz;
| }


int foo(int);
void bar() {
  int baz(int(foo(3)));
  int foo = baz;
}

Gives the same error, and is slightly less complex.

The following might help in finding the bug(?)

int foo(void);
void bar() {
  int baz(int(foo()));
  int foo = baz;
}

Gives:

~/tmp>g++ -c baz.cc
baz.cc: In function `void bar()':
baz.cc:4: warning: initialization to `int' from `int (*)(int (*)())' lacks a cast

While

int foo(void);
void bar() {
  int baz((int(foo())));
  int foo = baz;
}

compiles fine (note the extra () around the initialisation value of baz).

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]