This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++ compiler bug?
- To: paul dot robertson at locsoft dot com
- Subject: Re: g++ compiler bug?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 14 Jan 2000 00:57:34 +0100
- CC: egcs-bugs at egcs dot cygnus dot com
- References: <005b01bf5d0b$af4a2a80$320111ac@locsoft.com>
> I expected a compiler error from the statement
>
> i++++;
>
> and I do get an error under MSVC 6.0, but not from g++. I think this is
> a bug.
Thanks for your bug report. I can't reproduce your problem,
though. When I compile optest.cpp with egcs 2.91.66, the compiler says
optest.cpp: In function `int main()':
optest.cpp:40: warning: passing `const int_clone' as `this' argument of `const class int_clone int_clone::operator ++(int)' discards const
so the compiler recognizes a problem, produces a diagnostics, and the
accepts the code as an extension.
If you don't want the extension, you can use the -pedantic option. In
this case, the compiler says
optest.cpp: In function `int main()':
optest.cpp:40: warning: no `operator ++ (int)' declared for postfix `++', trying prefix operator instead
optest.cpp:40: no match for `++int_clone'
optest.cpp:14: candidates are: int_clone::operator ++() <near match>
optest.cpp:20: int_clone::operator ++(int)
and rejects the code.
Regards,
Martin