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]
Other format: [Raw text]

[Bug c++/48525] -O0 produces incorrect results for inlined functions sharing the same name.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48525

--- Comment #3 from Jon Roelofs <jroelofs at gmail dot com> 2011-04-09 17:08:06 UTC ---
(In reply to comment #2)
> (In reply to comment #0)
> > When compiling multiple files with inline functions which share the same
> > signature and name -O0 produces results inconsistent with -O1, -O2, and -O3
> > (which produce the expected result).
> 
> As Andreas said, this is an One Definition Rule violation, you need to make the
> functions static or put them in an anonymous namespace if you want to have a
> different definition in each file.
> 
> > gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
> 
> This compiler is not supported by the GCC project, the oldest supported release
> is 4.3
> 
> You should report issues with your compiler to Apple.

I get the same results on:
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)

Would it not be prudent for g++ to at least emit a warning when the ODR is
violated in cases like this?


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