Issue Details (XML | Word | Printable)

Key: PCC-347
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

relocation error with bool bit-field function address assignment

Created: 10/May/11 12:16 AM   Updated: 11/May/11 04:30 PM
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

Environment:
NetBSD petaure.lan 5.99.51 NetBSD 5.99.51 (PETAURE) #16: Sun May 8 22:56:08 CEST 2011 njoly@petaure.lan:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/PETAURE amd64
pcc 1.1.0.DEVEL 20110505 for x86_64-unknown-netbsd5.99.51, njoly@petaure.lan


 Description  « Hide
The following piece of code fails with a relocation error, when trying to assign a function address to a bool bit-field.
Removing the bit-field makes the problem disapear.

njoly@petaure [~]> cat bitfield.c
typedef struct { _Bool b : 1; } s_t;
int main() {
  s_t s;
  s.b = main;
  return 0; }
njoly@petaure [~]> pcc -o /dev/null bitfield.c; echo $?
bitfield.c, line 4: warning: illegal combination of pointer and integer
/tmp/ctm.08890c: In function `main':
(.text+0xd): relocation truncated to fit: R_X86_64_8 against symbol `main' defined in .text section in /tmp/ctm.08890c
1
njoly@petaure [~]> gcc -o /dev/null bitfield.c; echo $?
bitfield.c: In function 'main':
bitfield.c:4: warning: the address of 'main', will always evaluate as 'true'
0

NB: The pcc warning about pointer vs. integer combination is a bit misleading.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 11/May/11 04:30 PM
Fixed. The _Bool bitfield type were changed too early to its destination type causing normal bool conversions to fail.