RFR: JDK-8326974: ODR violation in macroAssembler_aarch64.cpp

Kim Barrett kbarrett at openjdk.org
Fri Mar 1 00:39:51 UTC 2024


On Thu, 29 Feb 2024 15:41:04 GMT, Andrew Haley <aph at openjdk.org> wrote:

> > > I think the patch suggested in bug was better, and in line with [Hotspot Style Guide](https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md), which says: "Global names must be unique, to avoid [One Definition Rule](https://en.cppreference.com/w/cpp/language/definition) (ODR) violations. A common prefixing scheme for related global names is often used. (This is instead of using namespaces, which are mostly avoided in HotSpot.)"
> > 
> > 
> > See also the section "Namespaces", and in particular the specific admonition against using anonymous namespaces.
> 
> Mmm, that's a shame. It seems to me that an anonymous namespace is best here, given that the classes should not be visible outside this translation unit, but implementation bugs in debuggers and linkers are a show stopper.

I completely agree :(  My experience on a different project was that anonymous namespaces had some significant
benefits, including potentially having such classes treated as implicitly final, with the optimizations that can come
from that.

I haven't looked at how well "modern" debugger versions cope with anonymous namespaces.  It seems like problems
there should have been fixed by now - anonymous namespaces are hardly new.  I was surprised that the usage proposed
here ran into linker problems though.  It would be nice if someone with good windows access could investigate that.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18056#issuecomment-1972222455


More information about the hotspot-dev mailing list