bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/30758] ODR violations in opcodes dir


From: vries at gcc dot gnu.org
Subject: [Bug binutils/30758] ODR violations in opcodes dir
Date: Thu, 17 Aug 2023 09:39:02 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30758

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|22395                       |
           Severity|normal                      |enhancement

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Alan Modra from comment #5)
> I'm guessing that it is the use of opcodes cgen headers in gdb itself that
> is triggering these warnings, not the use of those headers in opcodes.  I
> think I'd be looking at gdb/mep-tdep.c and gdb/or1k-tdep.c, perhaps trying
> to replace use of cgen types in structs defined there by void*.  Does it
> even make sense for g++ to complain about odr violations in extern "C"
> headers?

Thanks for the suggestion.

I went looking in this direction, and came across this doc (
https://en.cppreference.com/w/cpp/language/definition ) where it's suggested to
use unnamed namespaces to work around odr problems with types.

And indeed, this patch fixes the warnings:
...
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index fc786f09e44..8de2c588bad 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -48,8 +48,10 @@

 /* Get the user's customized MeP coprocessor register names from
    libopcodes.  */
+namespace {
 #include "opcodes/mep-desc.h"
 #include "opcodes/mep-opc.h"
+}



 /* The gdbarch_tdep structure.  */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index a11950584d7..b6ec91ab38e 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -23,8 +23,10 @@
 #define TARGET_OR1K
 #endif

+namespace {
 #include "opcodes/or1k-desc.h"
 #include "opcodes/or1k-opc.h"
+}

 /* General Purpose Registers */
 #define OR1K_ZERO_REGNUM          0
...

That's a fix on the gdb side.  So I guess this PR on the opcodes side is about
making that patch unnecessary, which would AFAIU involve generating uniquely
named types in cgen.

Of course, this PR could be closed as resolved-wontfix or some such if that's
deemed not a good idea or unnecessary.


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22395
[Bug 22395] ODR violations
-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]