This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Avoid undefined behavior in parse_number
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Wed, 03 Oct 2018 19:03:45 -0400
- Subject: [binutils-gdb] Avoid undefined behavior in parse_number
*** TEST RESULTS FOR COMMIT 20562150d8a894bc91657c843ee88c508188e32e ***
Author: Tom Tromey <tom@tromey.com>
Branch: master
Commit: 20562150d8a894bc91657c843ee88c508188e32e
Avoid undefined behavior in parse_number
-fsanitize=undefined pointed out that c-exp.y relied on undefined
behavior here:
if (c != 'l' && c != 'u')
n *= base;
...when a large hex constant "just fit" into a LONGEST, causing the
high bit to be set.
This fixes the problem by having the function work in an unsigned
type.
gdb/ChangeLog
2018-10-03 Tom Tromey <tom@tromey.com>
* c-exp.y (parse_number): Work in unsigned. Remove casts.