public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/102718] New: gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&)
@ 2021-10-12 20:44 msebor at gcc dot gnu.org
  2021-10-13  7:34 ` [Bug other/102718] " rguenth at gcc dot gnu.org
  2021-11-24 21:35 ` tschwinge at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-12 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102718

            Bug ID: 102718
           Summary: gtype-desc.c function redefinition error for
                    gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

This is to make a record of a bug in GCC's garbage collection machinery.  With
the following patch I get the errors below.  gtype-desc.c is a generated file
and the errors are due to the gengtype tool generating two definitions of the
gt_ggc_xxx functions, one for each specialization of the hash_map.  It seems
that it's not possible to have two hash_maps with keys of distinct types but
the same element type.

diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
index 85ffb725c02..dc98696132a 100644
--- a/gcc/diagnostic-spec.c
+++ b/gcc/diagnostic-spec.c
@@ -108,6 +108,7 @@ nowarn_spec_t::nowarn_spec_t (opt_code opt)
 /* A mapping from a 'location_t' to the warning spec set for it.  */

 GTY(()) xint_hash_map_t *nowarn_map;
+extern GTY(()) int_hash_map_t *nowarn_map_2;

 /* Return the no-warning disposition for location LOC and option OPT
    or for all/any otions by default.  */
diff --git a/gcc/diagnostic-spec.h b/gcc/diagnostic-spec.h
index 9b3aaaa3ce6..b1fb304c2f3 100644
--- a/gcc/diagnostic-spec.h
+++ b/gcc/diagnostic-spec.h
@@ -136,4 +136,8 @@ typedef hash_map<xint_hash_t, nowarn_spec_t>
xint_hash_map_t;
 /* A mapping from a 'location_t' to the warning spec set for it.  */
 extern GTY(()) xint_hash_map_t *nowarn_map;

+typedef int_hash <unsigned, 0, UINT_MAX> int_hash_t;
+typedef hash_map<int_hash_t, nowarn_spec_t> int_hash_map_t;
+extern GTY(()) int_hash_map_t *nowarn_map_2;
+
 #endif // DIAGNOSTIC_SPEC_H_INCLUDED


synchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual
-Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common 
-DHAVE_CONFIG_H -I. -I. -I/src/gcc/master/gcc -I/src/gcc/master/gcc/.
-I/src/gcc/master/gcc/../include -I/src/gcc/master/gcc/../libcpp/include
-I/src/gcc/master/gcc/../libcody  -I/src/gcc/master/gcc/../libdecnumber
-I/src/gcc/master/gcc/../libdecnumber/bid -I../libdecnumber
-I/src/gcc/master/gcc/../libbacktrace   -o gtype-desc.o -MT gtype-desc.o -MMD
-MP -MF ./.deps/gtype-desc.TPo gtype-desc.c
gtype-desc.c:3037:1: error: redefinition of ‘void gt_ggc_mx(nowarn_spec_t&)’
 gt_ggc_mx (struct nowarn_spec_t& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:3014:1: note: ‘void gt_ggc_mx(nowarn_spec_t&)’ previously defined
here
 gt_ggc_mx (struct nowarn_spec_t& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:3043:1: error: redefinition of ‘void gt_ggc_mx(int_hash<unsigned
int, 0, 4294967295>&)’
 gt_ggc_mx (int_hash<unsigned,0,UINT_MAX>& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:3020:1: note: ‘void gt_ggc_mx(int_hash<unsigned int, 0,
4294967295>&)’ previously defined here
 gt_ggc_mx (int_hash<location_t,0,UINT_MAX>& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:6999:1: error: redefinition of ‘void gt_pch_nx(nowarn_spec_t&)’
 gt_pch_nx (struct nowarn_spec_t& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:6976:1: note: ‘void gt_pch_nx(nowarn_spec_t&)’ previously defined
here
 gt_pch_nx (struct nowarn_spec_t& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:7005:1: error: redefinition of ‘void gt_pch_nx(int_hash<unsigned
int, 0, 4294967295>&)’
 gt_pch_nx (int_hash<unsigned,0,UINT_MAX>& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:6982:1: note: ‘void gt_pch_nx(int_hash<unsigned int, 0,
4294967295>&)’ previously defined here
 gt_pch_nx (int_hash<location_t,0,UINT_MAX>& x_r ATTRIBUTE_UNUSED)
 ^~~~~~~~~
gtype-desc.c:11395:1: error: redefinition of ‘void gt_pch_nx(nowarn_spec_t*,
gt_pointer_operator, void*)’
 gt_pch_nx (struct nowarn_spec_t* x ATTRIBUTE_UNUSED,
 ^~~~~~~~~
gtype-desc.c:11369:1: note: ‘void gt_pch_nx(nowarn_spec_t*,
gt_pointer_operator, void*)’ previously defined here
 gt_pch_nx (struct nowarn_spec_t* x ATTRIBUTE_UNUSED,
 ^~~~~~~~~
gtype-desc.c:11402:1: error: redefinition of ‘void gt_pch_nx(int_hash<unsigned
int, 0, 4294967295>*, gt_pointer_operator, void*)’
 gt_pch_nx (int_hash<unsigned,0,UINT_MAX>* x ATTRIBUTE_UNUSED,
 ^~~~~~~~~
gtype-desc.c:11376:1: note: ‘void gt_pch_nx(int_hash<unsigned int, 0,
4294967295>*, gt_pointer_operator, void*)’ previously defined here
 gt_pch_nx (int_hash<location_t,0,UINT_MAX>* x ATTRIBUTE_UNUSED,
 ^~~~~~~~~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug other/102718] gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&)
  2021-10-12 20:44 [Bug other/102718] New: gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&) msebor at gcc dot gnu.org
@ 2021-10-13  7:34 ` rguenth at gcc dot gnu.org
  2021-11-24 21:35 ` tschwinge at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-13  7:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102718

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |build
   Last reconfirmed|                            |2021-10-13

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Make gengtype wrap the output in

#ifndef GENGTYPE_DEFINED_<type>
#define GENGTYPE_DEFINED_<type>
...
#endif

so any duplicate gets weed out by the preprocessor ;)

gengtype is just a not very up to the task of GCC being written in C++ now ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug other/102718] gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&)
  2021-10-12 20:44 [Bug other/102718] New: gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&) msebor at gcc dot gnu.org
  2021-10-13  7:34 ` [Bug other/102718] " rguenth at gcc dot gnu.org
@ 2021-11-24 21:35 ` tschwinge at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2021-11-24 21:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102718

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|https://gcc.gnu.org/bugzill |
                   |a/show_bug.cgi?id=101292    |
   Last reconfirmed|2021-10-13 00:00:00         |2021-11-24
                 CC|                            |tschwinge at gcc dot gnu.org

--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
ACK.  See also my "'gengtype' generates duplicate functions" note in
<http://mid.mail-archive.com/87k0hhxwwb.fsf@euler.schwinge.homeip.net>/commit
r12-5050-g088199e5d0fc0d54f48af0783a2630a773bbb387 "Generalize
'gcc/input.h:struct location_hash'" -- "Thus, use a plain ol' '#define'".  ;-\

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-24 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 20:44 [Bug other/102718] New: gtype-desc.c function redefinition error for gt_ggc_xxx (int_hash<unsigned int, 0, 4294967295>&) msebor at gcc dot gnu.org
2021-10-13  7:34 ` [Bug other/102718] " rguenth at gcc dot gnu.org
2021-11-24 21:35 ` tschwinge at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).