Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000035 [cparser] other major always 2009-02-05 01:16 2009-05-15 16:51
Reporter Matze View Status public  
Assigned To Matze
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 0.9.8
  Product Build
Summary 0000035: cparser constant folding fails on big long long constants
Description Hello Matthias Braun,

yesterday I downloaded and compiled your wunderful cparser and,
well, you might be happy to hear about a small bug.
(or in libfirm?)

version: cparser-0.9.8, libfirm-1.16.0,
compiled with gcc 4.03, self compiled but gcc testsuite passed.
also used: Intel icc 9.0, platform: Debian Linux

Please have a look to the file ex_panic_ull.c in attachment
and test it with:
cparser -DONE -Wall -c ex_panic_ull.c
--> Panic: result of constant folding is not integer
cparser -DTWO -Wall -c ex_panic_ull.c
--> OK

Please let me know if you need further informations.

Gruesse nach Karlsruhe,
Steps To Reproduce
Additional Information I looked into it:

cparsers constant folding produces values in a long variable (in the compiler). Unfortunately you can construct constants bigger than a long. Seems we can't use any integer types for constant folding, but have to operate with tarvals inside cparser.
Tags No tags attached.
Attached Files c file icon ex_panic_ull.c [^] (1,538 bytes) 2009-02-05 01:16

- Relationships

-  Notes
Matze (administrator)
2009-02-05 01:17

Reduced testcase:

int main(void)
{ return 0x1fffffffffffffffULL ? 0 : 42; }
Matze (administrator)
2009-02-05 01:19

Interestingly this works nicely with 0xffffffffffffffffULL which cparser internally happily converts to a -1 long (which is probably not what we really want).
Matze (administrator)
2009-03-03 21:14

I just had another idea, we could create multiple fold_const functions. 1 that returns the result as a long (this should be fine for array indices and switches) and 1 that returns true/false in the case of non-zero/zero values (this should be fine for if, ?:), the 3rd case would return an ir_Const node (should be fine for initializer).
When I didn't miss something this should be enough to cover all cases without the need to fiddle around with tarvals in cparser.
Matze (administrator)
2009-03-08 01:22

fixed in r25630 as described in last comment.

- Issue History
Date Modified Username Field Change
2009-02-05 01:16 Matze New Issue
2009-02-05 01:16 Matze File Added: ex_panic_ull.c
2009-02-05 01:17 Matze Note Added: 0000052
2009-02-05 01:19 Matze Note Added: 0000053
2009-02-05 01:19 Matze Issue Monitored: Matze
2009-02-05 01:20 Matze Issue End Monitor: Matze
2009-02-05 01:23 Matze Additional Information Updated
2009-02-19 20:33 Tron Status new => confirmed
2009-03-03 21:14 Matze Note Added: 0000060
2009-03-08 01:22 Matze Note Added: 0000072
2009-03-08 01:22 Matze Assigned To => Matze
2009-03-08 01:22 Matze Status confirmed => resolved
2009-03-08 01:22 Matze Resolution open => fixed
2009-05-15 16:51 Matze Status resolved => closed

Mantis 1.1.5[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker