This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: py3k shouldn't use -fno-strict-aliasing anymore
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.0, Python 3.1, Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, alexandre.vassalotti, benjamin.peterson, donmez, stutzbach
Priority: normal Keywords: patch

Created on 2008-07-09 12:11 by donmez, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
strict-aliasing.patch donmez, 2008-07-09 12:11 Don't disable strict aliasing
strict-aliasing.patch stutzbach, 2010-03-30 06:13
python-3.1-issue3326.patch Arfrever, 2010-06-21 16:11
Messages (10)
msg69465 - (view) Author: Ismail Donmez (donmez) * Date: 2008-07-09 12:11
py3k branch is still using -fno-strict-aliasing but I tested with gcc
4.3.1 and there are no strict aliasing warnings when this flag is removed.

Attached patch for py3k branch removes this flag. After applying the
patch configure should be regenerated with autoconf.
msg69623 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-07-13 20:56
With gcc 4.2.3, I see a whole bunch of warnings:

Objects/exceptions.c: In function ‘UnicodeDecodeError_init’:
Objects/exceptions.c:1472: warning: dereferencing type-punned pointer
will break strict-aliasing rules

Objects/frameobject.c: In function ‘frame_setlineno’:
Objects/frameobject.c:151: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicode_DecodeUTF7Stateful’:
Objects/unicodeobject.c:1804: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:1815: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:1827: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeUTF8Stateful’:
Objects/unicodeobject.c:2140: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2147: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeUTF32Stateful’:
Objects/unicodeobject.c:2419: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2419: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2420: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2431: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeUTF16Stateful’:
Objects/unicodeobject.c:2693: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2693: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2694: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2705: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeUnicodeEscape’:
Objects/unicodeobject.c:2911: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2923: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:2962: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3004: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3018: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3030: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeRawUnicodeEscape’:
Objects/unicodeobject.c:3295: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3327: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3333: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘_PyUnicode_DecodeUnicodeInternal’:
Objects/unicodeobject.c:3502: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3512: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeASCII’:
Objects/unicodeobject.c:3875: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:3880: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_DecodeCharmap’:
Objects/unicodeobject.c:4176: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:4226: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:4249: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:4276: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_Join’:
Objects/unicodeobject.c:5724: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:5745: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c: In function ‘PyUnicodeUCS2_Format’:
Objects/unicodeobject.c:8841: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:9158: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Objects/unicodeobject.c:9223: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Python/bltinmodule.c: In function ‘source_as_string’:
Python/bltinmodule.c:513: warning: dereferencing type-punned pointer
will break strict-aliasing rules
./Modules/_codecsmodule.c: In function ‘unicode_internal_decode’:
./Modules/_codecsmodule.c:243: warning: dereferencing type-punned
pointer will break strict-aliasing rules
./Modules/_codecsmodule.c: In function ‘unicode_internal_encode’:
./Modules/_codecsmodule.c:700: warning: dereferencing type-punned
pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/_struct.c: In function ‘s_pack_into’:
/home/alex/src/python.org/py3k/Modules/_struct.c:1782: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/audioop.c: In function
‘audioop_findfit’:
/home/alex/src/python.org/py3k/Modules/audioop.c:480: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/audioop.c:480: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/audioop.c: In function
‘audioop_findfactor’:
/home/alex/src/python.org/py3k/Modules/audioop.c:537: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/audioop.c:537: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/audioop.c: In function
‘audioop_findmax’:
/home/alex/src/python.org/py3k/Modules/audioop.c:570: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/nismodule.c: In function
‘nis_xdr_ypmaplist’:
/home/alex/src/python.org/py3k/Modules/nismodule.c:293: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/nismodule.c: In function
‘nis_xdr_ypresp_maplist’:
/home/alex/src/python.org/py3k/Modules/nismodule.c:319: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/_cursesmodule.c: In function
‘PyCurses_UngetMouse’:
/home/alex/src/python.org/py3k/Modules/_cursesmodule.c:1846: warning:
dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_hk.c: In
function ‘big5hkscs_codec_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_hk.c:23:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_hk.c:23:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c: In
function ‘ksx1001_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:573:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:574:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c: In
function ‘jisx0208_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:609:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:610:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c: In
function ‘jisx0212_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:650:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:651:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c: In
function ‘jisx0213_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:688:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:690:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:692:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:694:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:696:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:698:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:700:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:700:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c: In
function ‘gb2312_init’:
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:957:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/alex/src/python.org/py3k/Modules/cjkcodecs/_codecs_iso2022.c:958:
warning: dereferencing type-punned pointer will break strict-aliasing rules
msg69625 - (view) Author: Ismail Donmez (donmez) * Date: 2008-07-13 21:02
Wow thats no good, I will test with -fstrict-aliasing to be sure, if there 
are such problems still we should start with fixing those towards 3.1 .
msg69646 - (view) Author: Ismail Donmez (donmez) * Date: 2008-07-14 06:50
I tested with -fstrict-aliasing -O3 and there is no aliasing warning,
this is with

gcc 4.3.1
x86_64 linux

what you see might be a compiler deficiency :-/
msg84600 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2009-03-30 18:09
I'm using gcc 3.4.4 (cygwin) and I get the sames warnings as Alexandre.

I examined a random sampling of the code generating the warnings, all of
which followed this pattern:

    some_function((some_type **) &var_of_some_other_type);

Since the variable isn't actually being dereferenced in the calling
function, the code isn't violating the strict aliasing rules.  I guess
gcc 4.3 is smart enough to suppress the warning in cases like this.

We could make the warning go away by replacing "(some_type **)" with
"(void *)", though that perhaps decreases readability.  Alternately we
can just disregard the warnings on older versions of gcc.
msg93883 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-12 00:02
I propose that we remove -fno-strict-aliasing for gcc >= 4.3.
msg101919 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-03-30 06:13
Attached is a patch for configure.in and configure that implements Benjamin's suggestion.  The patch sets things up to continue to use -fno-strict-aliasing on gcc versions that support -fno-strict-aliasing *and* generate spurious warnings without it.  Effectively, that means it adds -fno-strict-aliasing for gcc versions < 4.3.

I tested it with gcc-3.4.4 and gcc-4.3.2.  It added -fno-strict-aliasing with gcc-3.4.4 and did not with gcc-4.3.2, as desired.  

With the gcc-4.3.2 build, I did a "make test" and no tests failed.  

I also found that pybench ran around 1% faster with the patch.
msg101950 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-03-30 17:35
Thanks for the patch. Applied in r79499.
msg108282 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2010-06-21 16:11
I think that this change could be backported to 3.1 branch. It doesn't cause any additional warnings, which are absent in py3k branch (see issue #8623). r79499 doesn't merge cleanly, so I'm attaching the patch for 3.1 branch.
msg108287 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-06-21 17:04
2010/6/21 Arfrever Frehtes Taifersar Arahesis <report@bugs.python.org>:
>
> Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@GMail.Com> added the comment:
>
> I think that this change could be backported to 3.1 branch. It doesn't cause any additional warnings, which are absent in py3k branch (see issue #8623). r79499 doesn't merge cleanly, so I'm attaching the patch for 3.1 branch.

Thanks for the patch. Backported to in r82141.
History
Date User Action Args
2022-04-11 14:56:36adminsetgithub: 47576
2010-06-21 17:04:21benjamin.petersonsetmessages: + msg108287
2010-06-21 16:12:00Arfreversetfiles: + python-3.1-issue3326.patch
nosy: + Arfrever
messages: + msg108282

2010-03-30 17:35:08benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg101950
2010-03-30 06:13:49stutzbachsetfiles: + strict-aliasing.patch

messages: + msg101919
versions: + Python 3.2, Python 3.3
2009-10-12 00:02:00benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg93883
2009-03-30 18:09:44stutzbachsetnosy: + stutzbach

messages: + msg84600
versions: + Python 3.1
2008-07-14 06:50:39donmezsetmessages: + msg69646
2008-07-13 21:02:41donmezsetmessages: + msg69625
2008-07-13 20:56:03alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg69623
2008-07-09 12:11:19donmezcreate