Issue Details (XML | Word | Printable)

Key: PCC-194
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.

i386: xtemps optimisation runtime failure

Created: 28/Nov/10 09:44 PM   Updated: 19/Dec/10 05:41 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

NetBSD 5.99.40 NetBSD 5.99.40 (CALAMITY) #5: Sun Nov 28 11:01:52 CET 2010 i386
pcc 0.9.9 for i386-unknown-netbsdelf5.99.40, njoly@calamity.sis.pasteur.f Sat Nov 27 08:10:10 CET 2010

 Description  « Hide
The following sample code fails on i386 (works on amd64) at runtime when compiled with xtemps optimisation, and works without.

njoly@calamity [~]> cat sample.c
#include <assert.h>
#include <float.h>
#include <stdlib.h>

#define FABS(x) ((x) < 0.0 ? -(x) : (x))

int main() {
  double d = strtod(".5", NULL);
  assert(FABS(d - .5) < DBL_EPSILON);
  return 0; }

njoly@calamity [~]> pcc -o sample sample.c; echo $?
njoly@calamity [~]> ./sample; echo $?

njoly@calamity [~]> pcc -xtemps -o sample sample.c; echo $?
njoly@calamity [~]> ./sample; echo $?
assertion "FABS(d - .5) < DBL_EPSILON" failed: file "sample.c", line 9, function "main"
zsh: abort (core dumped) ./sample

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 19/Dec/10 05:41 PM
Fixed. Actually it was a bug in handling of whether a data type is allowed to be in register or not, and in the xtemps case even x87 registers could end up in registers inside ?: constructions which is not legal.
Note that this also failed on amd64 with long double variables.