This is the mail archive of the gcc-bugs@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]

Longstanding g++ parser bug?


/*

Hy there,

the present snippet may show a bug in g++ or may simply
show that I am still far from mastering C++.
The problem shows up with the latest release (2.95.2),
the egcs-1.1.2 release, and the snapshot 20000221
(I couldn't bootstrap ss-20000228).
I know it's mostly irrelevant, but the M$ and Borland compilers
happily compile this code.

Machine is:

$ uname -a
Linux zoltan.unisuv.it 2.2.14 #9 Fri Jan 7 06:04:02 CET 2000 i586
unknown

Compilers are:

$ /usr/bin/g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
$ /usr/local/bin/g++ -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
$ /usr/local/beta/bin/g++ -v       
Reading specs from
/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/2.96/specs
gcc version 2.96 20000221 (experimental)

Reproduce with:

$ /usr/bin/g++ -c bug.cc
bug.cc: In function `void bar()':
bug.cc:74: type specifier omitted for parameter
bug.cc:74: parse error before `5'
$ /usr/local/bin/g++ -c bug.cc
bug.cc: In function `void bar()':
bug.cc:74: type specifier omitted for parameter
bug.cc:74: parse error before `5'
$ /usr/local/beta/bin/g++ -c bug.cc
bug.cc: In function `void bar ()':
bug.cc:74: type specifier omitted for parameter
bug.cc:74: parse error before `5'

Keep up the great work,

    Roberto

--
Roberto Bagnara
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it

*/

struct a {};

class foo {
public:
  foo(a);
  foo(int, a);
  foo(a, int);
  foo(a, a);
};

void bar() {
  // g++ does not complain here: I believe he is right.
  foo p(a());
  foo q(5, a());
  foo r(a(), a());

  // g++ does complain here: I believe he is wrong.
  foo s(a(), 5);
}

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