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 01:16:31 UTC 2020


> On Jan 7, 2020, at 4:27 AM, Baesken, Matthias <matthias.baesken at sap.com> 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 .
> 
> Bug/webrev :
> 
> https://bugs.openjdk.java.net/browse/JDK-8236709
> 
> http://cr.openjdk.java.net/~mbaesken/webrevs/8236709.0/

I think I would prefer the C1 "namespace" disambiguator to be a prefix
rather than a suffix, to be consistent with usage in other parts of
HotSpot.  (GC code does that somewhat consistently, for example.)  I
don't recall seeing "namespace" suffixes used anywhere in HotSpot.

I've occasionally considered proposing that C2 code be wrapped in a
namespace. It grabs a bunch of very generic global type names ("Type",
"Block", &etc; really!?) that can be annoying. (Though the diet for
precompiled.hpp helped with that.) But anything like that is probably
out of scope for the immediate problem.

Giving C2 primacy of place (renaming the C1 class and letting C2 keep
the "good" name) seems consistent with existing practice.



More information about the hotspot-dev mailing list