https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114218
Bug ID: 114218 Summary: -Wdr could show constant values Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Target Milestone: --- It'd be a nice UX improvement if -Wodr showed the differing constant values rather than just the identifier. (This came up in the wild https://github.com/alsaplayer/alsaplayer/issues/28). a.h: ``` #ifndef MAGIC_NUMBER #define MAGIC_NUMBER 42 #endif struct number_storage { int MY_NUMBERS[MAGIC_NUMBER]; }; ``` b.cxx: ``` #include "a.h" struct number_storage collection_1; ``` c.cxx ``` #define MAGIC_NUMBER 100 #include "a.h" struct number_storage collection_2; int main() { } ``` ``` $ g++ b.cxx c.cxx -Wall -Wextra -flto a.h:5:8: warning: type ‘struct number_storage’ violates the C++ One Definition Rule [-Wodr] 5 | struct number_storage { | ^ a.h:5:8: note: a different type is defined in another translation unit 5 | struct number_storage { | ^ a.h:6:13: note: the first difference of corresponding definitions is field ‘MY_NUMBERS’ 6 | int MY_NUMBERS[MAGIC_NUMBER]; | ^ a.h:6:13: note: a field of same name but different type is defined in another translation unit 6 | int MY_NUMBERS[MAGIC_NUMBER]; | ^ a.h:5:8: note: array types have different bounds 5 | struct number_storage { | ^ ```