RFR: JDK-8326974: ODR violation in macroAssembler_aarch64.cpp
Julian Waters
jwaters at openjdk.org
Fri Mar 1 01:34:43 UTC 2024
On Fri, 1 Mar 2024 00:37:33 GMT, Kim Barrett <kbarrett 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.
It seemed to me that macOS ARM64 also experienced failures earlier, not just Windows, unless the test failure is unrelated? (I'm not very familiar with the JDK's testing framework)
I could help look into it, since I primarily develop on Windows, but I'd probably need time since I'm a little busy at the moment
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18056#issuecomment-1972284505
More information about the hotspot-dev
mailing list