[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2018-05-15 Thread Eitan Adler

Change by Eitan Adler :


--
nosy: +eitan.adler

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-05-02 Thread STINNER Victor

STINNER Victor added the comment:

dtoa.c is now compiled with -fno-string-aliasing (for any clang version, not 
only clang 4.0) on Python 3.5, 3.6 and 3.7.

It was decided to not touch dtoa.c to not diverge from upstream.

Thanks Dimitry Andric and Mark Dickinson for your reviews and support in this 
cryptic issue!

Note 1: We consider that Clang 4.0 is wrong, whereas GCC respects the C99 
standard for aliasing on unions. But I don't think that it matters much who is 
wrong or not :-)

Note 2: Python 2.7 already used -fno-strict-aliasing on all .c files because of 
its design of PyObject structures, fixed in Python 3.

--
resolution:  -> fixed
stage: backport needed -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-05-02 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 03a7ab77d2f75323e1f3e8b6a1c164e701d58bfb by Victor Stinner in 
branch '3.5':
bpo-30104: Use -fno-strict-aliasing on clang (#1376) (#1377)
https://github.com/python/cpython/commit/03a7ab77d2f75323e1f3e8b6a1c164e701d58bfb


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-05-02 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1485

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-05-02 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 809101f14f27ddb394cd77c477470761ecf99f41 by Victor Stinner in 
branch '3.6':
bpo-30104: Use -fno-strict-aliasing on clang (#1376)
https://github.com/python/cpython/commit/809101f14f27ddb394cd77c477470761ecf99f41


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-05-02 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1484

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-28 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 826f83f1d562a7b878499bc3af2267cfdfe5f2f9 by Victor Stinner in 
branch 'master':
bpo-30104: Only use -fno-strict-aliasing on dtoa.c (#1340)
https://github.com/python/cpython/commit/826f83f1d562a7b878499bc3af2267cfdfe5f2f9


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-28 Thread STINNER Victor

STINNER Victor added the comment:

I would like to fix FreeBSD CURRENT buildbots of Python 2.7, 3.5 and 3.6, so 
here my attempt to restrict the -fno-strict-aliasing option to the dtoa.c file: 
https://github.com/python/cpython/pull/1340

I chose to add the flag for any C compiler. If you think that a C compiler may 
not support that option, we can start by only adding the option on clang, and 
maybe add it on other C compilers if someone complains.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-28 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1451

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-24 Thread STINNER Victor

STINNER Victor added the comment:

> I also note that -fno-strict-aliasing is being included in 2.7's compile 
> arguments

Ah right, PyObject structures of Python 2 doesn't respect strict aliasing...

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-24 Thread Kubilay Kocak

Kubilay Kocak added the comment:

2.7 branch on koobs-freebsd-current worker doesn't appear to be failing 
currently, but there may be differences in (or a lack of equivalent) coverage 
compared to 3.*.

I also note that -fno-strict-aliasing is being included in 2.7's compile 
arguments:

cc -pthread -c -fno-strict-aliasing -OPT:Olimit=0 -g -O2 -g -O0 -Wall 
-Wstrict-prototypes

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-24 Thread STINNER Victor

STINNER Victor added the comment:

> This appears to require backporting to 3.6 and 3.5 which are also failing:

I'm aware of that and I plan to fix these versions as well (2.7 also, no?), but 
I would like to first decide if we "fix" dtoa.c aliasing, or if we restrict 
-fno-strict-aliasing flag on dtoa.c: see discussion on the issue #30124. It 
seems like restricting the flag to dtoa.c is the favorite option.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-24 Thread Kubilay Kocak

Changes by Kubilay Kocak :


--
stage:  -> backport needed
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-24 Thread Kubilay Kocak

Kubilay Kocak added the comment:

Thank you for investigating Victor.

This appears to require backporting to 3.6 and 3.5 which are also failing:

FAIL: test_repr (test.test_float.ReprTestCase)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.5.koobs-freebsd-current.nondebug/build/Lib/test/test_float.py",
 line 674, in test_repr
self.assertEqual(v, eval(repr(v)))
AssertionError: 5.3110001e+245 != 5.3110002e+245

--
Ran 42 tests in 0.242s

FAILED (failures=1, skipped=1)
7 tests failed again:
test_cmath test_float test_json test_marshal test_math
test_statistics test_strtod

--
versions: +Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

STINNER Victor added the comment:

Ok, the FreeBSD CURRENT buildbot is repaired: "AMD64 FreeBSD CURRENT
Debug 3.x is complete: Success".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 35f3d240ee5f0958034bd500949b08764e36f4dc by Victor Stinner in 
branch 'master':
bpo-30104: configure now detects when cc is clang (#1233)
https://github.com/python/cpython/commit/35f3d240ee5f0958034bd500949b08764e36f4dc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

STINNER Victor added the comment:

Oh... I only tested my configure patch on Linux using ./configure CC=clang, but 
the change has no effect on FreeBSD where $CC is /usr/bin/cc and so my code 
doesn't detect clang correctly.

I proposed https://github.com/python/cpython/pull/1233 which runs "cc 
--version" to check if it contains clang. I tested this change on FreeBSD: it 
works ;-) (it adds -fno-strict-aliasing)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1351

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread Eric V. Smith

Changes by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread Mark Dickinson

Mark Dickinson added the comment:

FWIW, I can confirm that adding `-fno-strict-aliasing` fixes all failing 
float-related tests on OS X.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

STINNER Victor added the comment:

Mark: "I seem the same issues on OS X (10.9.5) when compiling with clang 4.0 
from MacPorts. So this doesn't seem to be FreeBSD-specific."

I confirm, I reproduced the bug on Linux using Clang 4.0.

Mark: "But if that's what we have to do to maintain correctness with clang, 
then I guess we have little choice."

I pushed my change adding -fno-strict-aliasing compiler option to clang. I 
created the issue #30124 to fix the aliasing issue in dtoa.c.

I didn't check yet if we have to backport the -fno-strict-aliasing change, 
maybe we can wait until the aliasing issue is fixed and backport this future 
fix?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 28205b203a4742c40080b4a2b4b2dcd800716edc by Victor Stinner in 
branch 'master':
bpo-30104: Use -fno-strict-aliasing on clang (#1221)
https://github.com/python/cpython/commit/28205b203a4742c40080b4a2b4b2dcd800716edc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread Mark Dickinson

Changes by Mark Dickinson :


--
components: +Build

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

2017-04-21 Thread Mark Dickinson

Mark Dickinson added the comment:

I seem the same issues on OS X (10.9.5) when compiling with clang 4.0 from 
MacPorts. So this doesn't seem to be FreeBSD-specific.

Changing title and raising priority: failure for repr (and marshal, JSON, etc.) 
to roundtrip seems like a critical breakage to me.

mdickinson$ CC=/opt/local/bin/clang-mp-4.0 ./configure && make && ./python.exe 
-m test test_strtod
[... log from successful build omitted ...]
Run tests sequentially
0:00:00 [1/1] test_strtod
test test_strtod failed -- multiple errors occurred; run in verbose mode for 
details
test_strtod failed

1 test failed:
test_strtod

Total duration: 65 ms
Tests result: FAILURE

--
priority: normal -> critical
title: Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot -> 
clang 4.0 miscompiles dtoa.c, giving broken float parsing and printing

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com