https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103809
Bug ID: 103809 Summary: spurious reporting of structure redefinition Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: florin at iucha dot net Target Milestone: --- Consider the following program: /*********************************************************/ #include <concepts> namespace priv { template<typename Value> struct Struct {}; } #ifdef SHOW_BUG template<std::integral Integral> struct priv::Struct<Integral> {}; // This way results in: // <source>:19:14: error: redefinition of 'struct priv::Struct<Integral>' // 19 | struct priv::Struct<Float> {}; // | ^~~~~~~~~~~~~ template<std::floating_point Float> struct priv::Struct<Float> {}; #else namespace priv { template<std::integral Integral> struct Struct<Integral> {}; template<std::floating_point Float> struct Struct<Float> {}; } #endif int main() {} /*********************************************************/ Compiling with "g++ -std=c++20 -DSHOW_BUG" results in <source>:19:14: error: redefinition of 'struct priv::Struct<Integral>' 19 | struct priv::Struct<Float> {}; | ^~~~~~~~~~~~~ <source>:12:14: note: previous definition of 'struct priv::Struct<Integral>' 12 | struct priv::Struct<Integral> {}; | ^~~~~~~~~~~~~~~~ ASM generation compiler returned: 1 <source>:19:14: error: redefinition of 'struct priv::Struct<Integral>' 19 | struct priv::Struct<Float> {}; | ^~~~~~~~~~~~~ <source>:12:14: note: previous definition of 'struct priv::Struct<Integral>' 12 | struct priv::Struct<Integral> {}; | ^~~~~~~~~~~~~~~~ Compiling without SHOW_BUG results in no error. (Bug found by my colleague, Ramon Sibello).