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]
Other format: [Raw text]

[Bug c/32805] New: strange error from winavr 20070525


avr-gcc -S -mmcu=atmega16hva -I. -gstabs -DF_CPU=4000000UL -Os -funsigned-char
-funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes
-Wa,-adhlns=test.lst -std=gnu99 -MD -MP -MF .dep/test.s.d test.c -o test.s
test.c:7:9: error: invalid suffix "+4" on integer constant
make.exe: *** [test.s] Error 1

code here

int main(void)
{
int array[0xFF] = {0};

for (int i=0;i<8;i++)
{
array[0x9E+4*i] = 0x9E + 4 * i;
}

return 0;
} 

analysis by Jörg Wunsch:

The lexer (lex_number() in libcpp/lex.c) tries to parse numbers
regardless of whether they might be floating-point or integer numbers.
As such, it not only considers regular digits, but also wants to match
a possible exponent sign of a floating-point number to become part of
the number (macro VALID_SIGN, in libcpp/internal.h). For this, it
looks at the previous character to see whether it's an `e' or `E' (or
`p' and `P' if hexadecimal floats are supported). So now that's the
point where it misidentifies your "0x9E+4" string: it passes it on as
a potential floating-point number, but the parser then parses it
(correctly) as a hexadecimal integer, and complains about the not-hex
"+4" trailing substring being an invalid integer suffix. (Valid
integer suffices are U, UL, and so on.)


-- 
           Summary: strange error from winavr 20070525
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: xiewensheng at gmail dot com


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


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