This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cpp bug with \r


In case there is a \r found in the end of a define line
which is extended to two lines with \ , the preprocessor is confused
and does not process it correctly :

1: -------------------------
On the program :

#define m 1 +\
100

int main ( int argc , char **argv ) {
  return m;
}

2: -------------------------
who's octal dump is ( od -c )
0000000   #   d   e   f   i   n   e       m       1       +   \  \r  \n
0000020   1   0   0  \r  \n  \r  \n   i   n   t       m   a   i   n    
0000040   (       i   n   t       a   r   g   c       ,       c   h   a
0000060   r       *   *   a   r   g   v       )       {  \r  \n        
0000100   r   e   t   u   r   n       m   ;  \r  \n   }  \r  \n
0000116

Remark : there is a \r at the end of the first line. 

3: -----------------------------
gcc -E produces :

# 1 "try.c"

100

int main ( int argc , char **argv ) {
  return 1 +\ ;
}

which of course does not compile.
We found out this problem when moving files from windows to unix.

gcc version : 
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)
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386
Linux/ELF)

Thanks 

--

  David Er-el      

  Contact info in :  http://www.cs.huji.ac.il/~derel



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]