Skip to content

warning: dereferencing type-punned pointer will break strict-aliasing rules #72304

Description

@serhiy-storchaka
BPO 28117
Nosy @mdickinson, @tiran, @serhiy-storchaka, @ma8ma, @ekul00
Dependencies
  • bpo-16113: Add SHA-3 and SHAKE (Keccak) support
  • Files
  • keccak_warnings.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2016-09-13.07:11:54.190>
    labels = ['extension-modules', 'build', '3.7']
    title = 'warning: dereferencing type-punned pointer will break strict-aliasing rules'
    updated_at = <Date 2018-09-26.10:24:44.124>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-09-26.10:24:44.124>
    actor = 'ekul'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2016-09-13.07:11:54.190>
    creator = 'serhiy.storchaka'
    dependencies = ['16113']
    files = ['44847']
    hgrepos = []
    issue_num = 28117
    keywords = ['patch']
    message_count = 5.0
    messages = ['276193', '276210', '277546', '306005', '326439']
    nosy_count = 5.0
    nosy_names = ['mark.dickinson', 'christian.heimes', 'serhiy.storchaka', 'masamoto', 'ekul']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue28117'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. serhiy-storchaka commented on Sep 13, 2016

      @serhiy-storchaka
      MemberAuthor

      In file included from /home/serhiy/py/cpython/Modules/_sha3/sha3module.c:113:0:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c: In function ‘_PySHA3_KeccakP1600_SetBytesInLaneToZero’:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c:97:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      low = *((UINT32*)(laneAsBytes+0));
      ^
      In file included from /home/serhiy/py/cpython/Modules/_sha3/sha3module.c:113:0:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c: In function ‘_PySHA3_KeccakP1600_AddBytesInLane’:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c:152:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      low = *((UINT32*)(laneAsBytes+0));
      ^
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c: In function ‘_PySHA3_KeccakP1600_ExtractBytesInLane’:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c:296:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      *((UINT32*)(laneAsBytes+0)) = low;
      ^
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c: In function ‘_PySHA3_KeccakP1600_ExtractAndAddBytesInLane’:
      /home/serhiy/py/cpython/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c:369:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      *((UINT32*)(laneAsBytes+0)) = low;
      ^

    2. tiran commented on Sep 13, 2016

      @tiran
      Member
    3. serhiy-storchaka commented on Sep 27, 2016

      @serhiy-storchaka
      MemberAuthor

      Proposed patch eliminates warnings.

    4. ma8ma commented on Nov 10, 2017

      ma8mamannequin
      Mannequin

      Serhiy, would you open a PR? Your patch looks good to me.
      I've been looking at the warning on my machine (ubuntu 16.04 x86), it's a bit annoying to me.

    5. ekul00 commented on Sep 26, 2018

      ekul00mannequin
      Mannequin

      I just got this set of warnings while building 3.6.6 on RasPi Debian9/ARM. Good to know the warning is spurious.

      Just finding my way here - is Serhiy's patch above a working 2016 fix for this that got stuck in review? I couldn't find a PR for it. If the warning _is_ spurious it would be great to patch it.

    6. transferred this issue fromon Apr 10, 2022
    7. serhiy-storchaka commented on Aug 5, 2026

      @serhiy-storchaka
      MemberAuthor

      Modules/_sha3/kcp/ no longer exists: the Keccak Code Package was replaced with tiny_sha3 in bpo-47098 (GH-32060), and SHA-3 is now implemented with HACL*. The warning is gone with the code that caused it.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifebuildThe build process and cross-buildextension-modulesC modules in the Modules dir

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions