Bug report

Philippe Bouchard boucp00@DMI.USherb.CA
Sun Oct 31 23:03:00 GMT 1999


The program:
#include <iostream.h>
#define SEARCH(array, target)                           
\
   ({                                                   
\
      __label__ found;                                  
\
      typeof (target) _SEARCH_target =
(target);         \
      typeof (*(array)) *_SEARCH_array
= (array);        \
      int i, j;                                         
\
      int value;                                        
\
      for (i = 0; i < max; i++)                         
\
         for (j = 0; j
< max; j++)                      
\
           
if (_SEARCH_array[i][j] == _SEARCH_target)   \
           
{ value = i; goto found; }                  
\
      value = -1;                                       
\
   found:                                               
\
      value;                                            
\
   })
void main() {
   char array[] = "I have found a bug...";
   int const max = strlen(array);
   cout<<"Found @ "<<SEARCH(&array, 'g')<<endl;
   }
Produces:
[...]$ g++ labels.cc
labels.cc: In function `int main(...)':
labels.cc:22: jump to label `found'
labels.cc:22:   from here
labels.cc:22:   crosses initialization of `char (* _SEARCH_array)[22]'
labels.cc:22:   crosses initialization of `char _SEARCH_target'
With version:
[...]$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
PAB



More information about the Gcc-bugs mailing list