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,
^~~~~~~~~