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]

Re: g++ compiler bug?


> 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

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