Bug 10241 - incorrect parsing of floating point literals
Summary: incorrect parsing of floating point literals
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-04 17:26 UTC by Mark Shinwell
Modified: 2009-06-05 06:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Shinwell 2009-06-04 17:26:49 UTC
gas fails to parse floating point literals correctly when the first character of the literal is '0' and the 
second character is a letter of the alphabet.  For example, 0e-4 parses as -4, and even 0e0e-4 is 
accepted (and parses to zero).  The issue is clearly most serious in the 0e-4 case.

I think this is a host/build/target-triplet independent problem.  The offending code is in 
gas/read.c:s_float_space:

  /* Skip any 0{letter} that may be present.  Don't even check if the
   * letter is legal.  */
  if (input_line_pointer[0] == '0'
      && ISALPHA (input_line_pointer[1]))
    input_line_pointer += 2;

It seems unclear what the purpose of this code is.

Test case, test.s (zeros interspersed to make the output easier):

	.data
	.double	0e0e-4
        .double 0
	.double	0e-4
	.double	0
        .double -4.0
	.double	0

$ ./install/bin/x86_64-pc-linux-gnu-as -o test.o test.s && ./install/bin/x86_64-pc-linux-gnu-
objdump -Dr test.o
Comment 1 Alan Modra 2009-06-05 06:24:29 UTC
Please read the gas info doc, node Flonums.  Your floating point literals are
invalid.