Issue Details (XML | Word | Printable)

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

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

sign issue with tanh/tanhf(-0.0) result

Created: 23/Sep/11 10:55 AM   Updated: 23/Mar/12 06:04 PM
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

NetBSD 5.99.55 NetBSD 5.99.55 (LYNCHE) #2: Mon Sep 12 10:56:41 CEST 2011 amd64
pcc 1.1.0.DEVEL 20110922 for x86_64-unknown-netbsd5.99.55

 Description  « Hide
The following sample code do fail with pcc on amd64, but succeed with gcc (works fine for i386 with both pcc and gcc).

njoly@lynche [tmp/pcc]> cat sample.c

#include <assert.h>
#include <err.h>
#include <math.h>

int main() {
  double d;
  float f;

  f = tanhf(-0.0);
  warnx("%e %d", f, signbit(f));
  assert(signbit(f) != 0);

  d = tanh(-0.0);
  warnx("%e %d", d, signbit(d));
  assert(signbit(d) != 0);

  return 0; }

njoly@lynche [tmp/pcc]> pcc -g -Wall -Werror -o sample sample.c -lm
njoly@lynche [tmp/pcc]> ./sample
sample: 0.000000e+00 0
assertion "signbit(f) != 0" failed: file "sample.c", line 12, function "main"
zsh: abort (core dumped) ./sample

njoly@lynche [tmp/pcc]> gcc -g -Wall -Werror -o sample sample.c -lm
njoly@lynche [tmp/pcc]> ./sample
sample: -0.000000e+00 1
sample: -0.000000e+00 1

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson made changes - 17/Mar/12 05:55 PM
Field Original Value New Value
Anders Magnusson made changes - 23/Mar/12 06:04 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]