Issue Details (XML | Word | Printable)

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

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

structure initialisation issue

Created: 26/Dec/10 01:54 AM   Updated: 27/Dec/10 08:04 PM
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

NetBSD petaure.lan 5.99.41 NetBSD 5.99.41 (PETAURE) #10: Sat Dec 25 23:42:08 CET 2010 njoly@petaure.lan:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/PETAURE amd64
pcc 0.9.9 for x86_64-unknown-netbsd5.99.41, njoly@petaure.lan Sat Dec 25 23:52:10 CET 2010

 Description  « Hide
The following sample show bad results :

njoly@petaure [check/pcc]> cat yy.c
#include <stdio.h>

typedef struct { long double value; const char *string; } yy_t;

int main() {
  static yy_t data[1] = { { 1.234L, "1.234" } };
  printf("%Lf %s\n", data[0].value, data[0].string);
  return 0; }
njoly@petaure [check/pcc]> pcc -g -o yy yy.c
njoly@petaure [check/pcc]> ./yy
1.234000 (null)

The string member got NULL instead of expected string "1.234".
Either removing the static keyword or using double type instead of long double make it work as expected.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 27/Dec/10 08:04 PM
fixed now, thanks. long double is 128 bits on amd64, not 96 as on i386, and the i386-copied code were not fixed.