<< Back to previous view

[PCC-387] offsetof cannot be used in bitfields: constant expected Created: 25/Mar/12  Updated: 26/Mar/12

Status: Resolved
Project: pcc
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Nicolas Joly Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
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   
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


 Comments   
Comment by Anders Magnusson [ 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.
Comment by Anders Magnusson [ 26/Mar/12 09:33 PM ]
Changed the optimization routines to iterate to do its best work, and also added ?: support in optim().
Generated at Fri Oct 31 10:56:34 CET 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.