This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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 gdb/17607] New: With some locales, entering a valid floating point number gives "Invalid number"


https://sourceware.org/bugzilla/show_bug.cgi?id=17607

            Bug ID: 17607
           Summary: With some locales, entering a valid floating point
                    number gives "Invalid number"
           Product: gdb
           Version: 7.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: fabrizio.ge at tiscali dot it

Using Ubuntu 14.10 and GNU gdb (Ubuntu 7.8-1ubuntu4) 7.8.0.20141001-cvs. Env
variable LC_NUMERIC has value it_IT.UTF-8

(gdb) p 1.0
Invalid number "1.0".

A little investigation shows that gdb assumes that floating-point numbers use .
as decimal mark, as these lines from c-exp.y show

            else if (!got_dot && *p == '.')
              got_dot = 1;

but, later, the function parse_float() (in parse.c) feeds the string into
sscanf

  num = sscanf (copy, "%" DOUBLEST_SCAN_FORMAT "%n", d, &n);

and, apparently, sscanf is locale-sensitive, so, if the current locale has , as
decimal mark, sscanf will leave everything past the . sign unscanned. gdb,
then, notices that something is unscanned and says "Invalid number"

It starts working again if the value of LC_NUMERIC is changed to en_US.UTF8.
However, having something that breaks with some locales is a bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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