Compile the source code pasted below with "-Os -Wuninitialized" using C++. You should get the following warnings: uninit.cpp: In function 'int foo()': uninit.cpp:13: warning: 'range$begin' is used uninitialized in this function uninit.cpp: In function 'int bar()': uninit.cpp:21: warning: 'range$end' may be used uninitialized in this function where the '.' has been secretly replaced by '$'. This used to be a problem with C and ObjC in the past also, but appears fixed now. ============ uninit.cpp ================== /* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* Check that unused warnings triggered by the optimizer contain '.' rather than '$' in them. */ /* { dg-do compile } */ /* { dg-options "-Os -Wuninitialized" } */ typedef struct Range { long begin, end; } Range; int foo(void) { Range range; while(range.begin != 0) { } /* { dg-warning ".range\\.begin. is used uninitialized in this function" } */ return 0; } extern int baz(void); int bar(void) { Range range; /* { dg-warning ".range\\.end. may be used uninitialized in this function" } */ do { if(baz()) range.end = 2; } while(range.end != 0); return 0; }
(In reply to comment #0) > Compile the source code pasted below with "-Os -Wuninitialized" using C++. You should get the > following warnings: > > uninit.cpp: In function 'int foo()': > uninit.cpp:13: warning: 'range$begin' is used uninitialized in this function > uninit.cpp: In function 'int bar()': > uninit.cpp:21: warning: 'range$end' may be used uninitialized in this function > > where the '.' has been secretly replaced by '$'. This used to be a problem with C and ObjC in the past > also, but appears fixed now. The reason why it is not fixed for the C++ front-end is because no C++ maintainer did what RTH requested for this to be fixed, see PR 14329. Oh and this is a dup of bug 14329. *** This bug has been marked as a duplicate of 14329 ***