Issue Details (XML | Word | Printable)

Key: PCC-251
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Detlef Riekenberg
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

math.h failed to compile with -D__OPTIMIZE__

Created: 22/Feb/11 07:35 PM   Updated: 09/Apr/11 11:17 AM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File mathinline.c (0.1 kB)
2. File mathinline_pcc-E-D__OPTIMIZE__.c (41 kB)
3. File mathinline_pcc-E.c (40 kB)

Environment: i386/linux

 Description  « Hide
pcc failed to compile <math.h>, when __OPTIMIZE__ is defined (using -O or -D__OPTIMIZE__).
(math.h is using <bits/mathinline.h> in that case)

Sample code and preprocessed version is attached.

$ pcc mathinline.c -E -D__OPTIMIZE__ -o mathinline_pcc-E-D__OPTIMIZE__.c
$ pcc mathinline_pcc-E-D__OPTIMIZE__.c -c
mathinline_pcc-E-D__OPTIMIZE__.c, line 2625: __f undefined
mathinline_pcc-E-D__OPTIMIZE__.c, line 2625: syntax error
mathinline_pcc-E-D__OPTIMIZE__.c, line 2636: __d undefined
mathinline_pcc-E-D__OPTIMIZE__.c, line 2636: syntax error
mathinline_pcc-E-D__OPTIMIZE__.c, line 2646: __l undefined
mathinline_pcc-E-D__OPTIMIZE__.c, line 2646: syntax error

compilation works without "-D__OPTIMIZE__"

By by ... Detlef

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 23/Feb/11 06:39 PM
Yetch, they use a since-very-long deprecated way of writing initializers:

union { float __f; int __i; } __u = { __f: __x };

The gcc documentation says:
> Another syntax which has the same meaning, obsolete since GCC 2.5, is `fieldname:', as shown here:
> struct point p = { y: yvalue, x: xvalue };

Anders Magnusson added a comment - 23/Feb/11 07:35 PM
To add support for it will affect quite much code so it's not likely that a fix for this will occur in 1.0.

Richard Spencer added a comment - 02/Apr/11 08:52 PM - edited
I have found the exact same issue with "bits/mathinline.h" (and fix to not use -O[3]). I appreciate it's one of the downsides of using the system includes; however I'm surprised that pcc gets past the #ifdef guards.

Possibly a solution would be for pcc to identify/test against __GNU_PREREQ() and friends a little better? (Half the errors went away with -D__NO_MATH_INLINES=1 but that's as far as I got with this before giving up, and this may well be platform-specific.)

Edit2: Remove reference with known issue re: './configure --disable-gcc-compat'

Anders Magnusson added a comment - 02/Apr/11 10:06 PM
The only correct way to deal with this is to in some way support the deprecated way of assigning values to specific members.
Disabling gcc-compat is a dead-end, almost nothing compiles without it. I'll try to fix this now that 1.0 is out of the door.

Anders Magnusson added a comment - 09/Apr/11 11:17 AM
fixed now in -current.