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 <[EMAIL PROTECTED]> */
/* 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;
}

-- 
           Summary: Spurious '$' in warning messages
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zlaski at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21349

Reply via email to