This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On May 10 14:57, Agner Fog wrote: > Bug description: > > The sqrtl function under Clang causes an access violation when the argument > is negative. > > This error occurs only under Cygwin. > > This error occurs only with the sqrtl function, not with sqrt or sqrtf > > Attached: > > sqrt.cpp: program to reproduce the error. Compile clang sqrt.cpp and run > ./a.exe Thanks for the testcase. This looks like a bug in clang-5.0. It does not occur when building the testcase with gcc, nor does it occur when building with clang-4.0. Looking with GDB, it seems the conversion from float to long double is screwed up. The sequence converting float to long double prior to calling sqrtl is very different: With gcc: Thread 1 "sqrtl" hit Temporary breakpoint 1, main () at sqrtl.c:6 6 float b = sqrtl(a); (gdb) s sqrtl (x=-1) at /home/corinna/src/cygwin/vanilla/winsup/cygwin/math/sqrt.def.h:69 69 __FLT_TYPE res = __FLT_CST (0.0); (gdb) n 70 int x_class = fpclassify (x); (gdb) p x $1 = -1 (gdb) x/4x &x 0xffffcaf0: 0x00000000 0x80000000 0x0004bfff 0x00000006 => 0x100401093 <main+19>: lea -0x20(%rbp),%rax => 0x100401097 <main+23>: fstpt -0x30(%rbp) => 0x10040109a <main+26>: lea -0x30(%rbp),%rdx => 0x10040109e <main+30>: mov %rax,%rcx => 0x1004010a1 <main+33>: callq 0x100401110 <sqrtl> With clang: Thread 1 "sqrtl" hit Temporary breakpoint 1, main () at sqrtl.c:6 6 float b = sqrtl(a); (gdb) s sqrtl (x=<invalid float value>) at /home/corinna/src/cygwin/vanilla/winsup/cygwin/math/sqrt.def.h:69 69 __FLT_TYPE res = __FLT_CST (0.0); (gdb) n 70 int x_class = fpclassify (x); (gdb) p x $1 = <invalid float value> (gdb) x/4x &x 0xffffcb10: 0x00000000 0x00000000 0x00040524 0x00000006 => 0x100401096 <main+22>: movabs $0x100402010,%rax => 0x1004010a0 <main+32>: flds (%rax) => 0x1004010a2 <main+34>: mov %rsp,%rax => 0x1004010a5 <main+37>: fstpt 0x20(%rax) => 0x1004010a8 <main+40>: callq 0x100401120 <sqrtl> Corinna -- Corinna Vinschen Cygwin Maintainer
Attachment:
signature.asc
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |