RFR [XS]: 8236709: struct SwitchRange in HS violates C++ One Definition Rule - was RE: struct SwitchRange and C++ One Definition Rule [-Wodr]
Kim Barrett
kim.barrett at oracle.com
Wed Jan 8 00:58:30 UTC 2020
> On Jan 7, 2020, at 7:23 PM, David Holmes <david.holmes at oracle.com> wrote:
>
> Hi Matthias,
>
> On 7/01/2020 7:27 pm, Baesken, Matthias wrote:
>> Hello, please review this small fix for an issue that I was running into when experimenting with gcc8 and the -flto compiler flag .
>> When building with those flags, the gcc8 warns that the SwitchRange classes in HS code violate the C++ One Definition Rule .
>> So I renamed one of those 2 SwitchRange classes .
>
> Could you instead put the ./share/opto/parse2.cpp version inside an anonymous namespace? It seems to me that both SwitchRange classes are intended for use in a single compilation unit, so if we can make that more obvious that seems better than solving the name clash.
At one time I considered proposing changing the HotSpot Style Guide to
permit (and indeed encourage, as there are some performance benefits too)
the use of anonymous namespaces. However, I discovered that debuggers
don't seem to like them at all, so dropped that idea.
https://groups.google.com/forum/#!topic/mozilla.dev.platform/KsaG3lEEaRM
Suggests Visual Studio debugger might not be able to refer to
anonoymous namespace symbols, so can't set breakpoints in them &etc.
Though the discussion seems to go back and forth on that.
https://firefox-source-docs.mozilla.org/tools/lint/coding-style/coding_style_cpp.html
Search for "Anonymous namespaces"
Suggests preferring "static" to anonymous namespaces where applicable,
because of poor debugger support for anonymous namespaces.
https://sourceware.org/bugzilla/show_bug.cgi?id=16874
Bug for similar gdb problems.
More information about the hotspot-dev
mailing list