<< Back to previous view

[PCC-347] relocation error with bool bit-field function address assignment Created: 10/May/11  Updated: 11/May/11

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 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

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
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'

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

Comment by Anders Magnusson [ 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.
Generated at Tue Oct 17 17:09:27 CEST 2017 using JIRA Enterprise Edition, Version: 3.13.1-#333.