Issue Details (XML | Word | Printable)

Key: PCC-387
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Nicolas Joly
Votes: 0
Watchers: 0
Operations

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

offsetof cannot be used in bitfields: constant expected

Created: 25/Mar/12 03:33 PM   Updated: 26/Mar/12 09:33 PM
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

Environment:
NetBSD petaure.lan 6.99.4 NetBSD 6.99.4 (PETAURE) #9: Sun Mar 25 12:44:01 CEST 2012 njoly@petaure.lan:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/PETAURE amd64
pcc 1.1.0.DEVEL 20120325 for x86_64-unknown-netbsd6.99.4


 Description  « Hide
The following sample that tries to use offsetof for bitfield setup, do fail with pcc on amd64;
no problem with amd64 gcc, nor i386 pcc.

njoly@petaure [tmp/pcc]> cat sample.c
#include <stddef.h>

struct s1 { char c1; char c2; };
struct s3 { int i : offsetof(struct s1, c2) ? 1 : -1; };

int main() { return 0; }

njoly@petaure [~]> pcc --version
pcc 1.1.0.DEVEL 20120325 for x86_64-unknown-netbsd6.99.4
njoly@petaure [tmp/pcc]> pcc -g -Wall -Werror -o sample sample.c; echo $?
sample.c, line 4: constant expected
1

njoly@petaure [~]> cc --version | head -n 1
cc (NetBSD nb2 20110806) 4.5.3
njoly@petaure [tmp/pcc]> cc -g -Wall -Werror -o sample sample.c; echo $?
0

njoly@petaure [netbsd32:pcc]> pcc --version
pcc 1.1.0.DEVEL 20120325 for i386-unknown-netbsdelf6.99.4
njoly@petaure [netbsd32:pcc]> pcc -g -Wall -Werror -o sample sample.c; echo $?
0


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson made changes - 26/Mar/12 09:37 AM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Anders Magnusson added a comment - 26/Mar/12 09:39 AM
Yetch, which obscure construct :-/
The problem is that early conversion of constants isn't done. Have to fix that.

Anders Magnusson added a comment - 26/Mar/12 09:33 PM
Changed the optimization routines to iterate to do its best work, and also added ?: support in optim().

Anders Magnusson made changes - 26/Mar/12 09:33 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]