GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Compiler warning for `_Py_InIntegralTypeRange` · Issue #97786 · python/cpython

Compiler warning for _Py_InIntegralTypeRange #97786

New issue
Copy link
New issue
Copy link
Closed
Closed
Compiler warning for _Py_InIntegralTypeRange#97786
Copy link
Assignees
mdickinson
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@brettcannon
brettcannon
opened on Oct 3, 2022
Issue body actions

Bug report

Python/pytime.c:297:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
    if (!_Py_InIntegralTypeRange(time_t, intpart)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:72:45: note: expanded from macro '_Py_InIntegralTypeRange'
    (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                         ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:61:88: note: expanded from macro '_Py_IntegralTypeMax'
    (_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Python/pytime.c:352:14: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
        if (!_Py_InIntegralTypeRange(time_t, intpart)) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:72:45: note: expanded from macro '_Py_InIntegralTypeRange'
    (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                         ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:61:88: note: expanded from macro '_Py_IntegralTypeMax'
    (_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Python/pytime.c:518:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
    if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:72:45: note: expanded from macro '_Py_InIntegralTypeRange'
    (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                         ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_pymath.h:61:88: note: expanded from macro '_Py_IntegralTypeMax'
    (_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
3 warnings generated.

Your environment

  • CPython main (3.11.0rc2 time frame)
  • clang 10

Linked PRs

  • gh-97786: Fix compiler warnings in pytime.c #101826
  • [3.11] gh-97786: Fix compiler warnings in pytime.c (GH-101826) #102062
  • [3.10] gh-97786: Fix compiler warnings in pytime.c (GH-101826) #102150
Reacted by Gregory P. Smith

Activity

  1. brettcannon
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-C-API
    on Oct 3, 2022
  2. brettcannon commented on Oct 3, 2022

    @brettcannon
    brettcannon
    on Oct 3, 2022
    MemberAuthor
    More actions

    Reported for WebAssembly builds at #97786 .

  3. benjaminp
    added 2 commits that reference this issue on Oct 3, 2022

    pytime: Use llround for double -> integer conversions.

    This issue will close once commit 2b5438e is merged into the 'main' branch.
    2b5438e

    pytime: Use llround for double -> integer conversions.

    This issue will close once commit 8f03546 is merged into the 'main' branch.
    8f03546
  4. vstinner commented on Oct 4, 2022

    @vstinner
    vstinner
    on Oct 4, 2022
    Member
    More actions

    See also #83458.

    This bug was one of my motivations to add math.nextafter() and math.ulp(), to help me understanding this issue :-D

  5. vstinner commented on Oct 4, 2022

    @vstinner
    vstinner
    on Oct 4, 2022
    Member
    More actions

    See also #78604.

  6. vstinner commented on Oct 4, 2022

    @vstinner
    vstinner
    on Oct 4, 2022
    Member
    More actions

    My abandonned attempt to fix this warning using nextafter(): PR #17933. I abandonned my PR because I didn't have time to work on it.

  7. gpshead
    added
    3.11only security fixesonly security fixes
    3.10 (EOL)end of lifeend of life
    3.12only security fixesonly security fixes
    on Feb 5, 2023
  8. gpshead commented on Feb 5, 2023

    @gpshead
    gpshead
    on Feb 5, 2023
    Member
    More actions

    cc: @mdickinson as a numeric details expert

  9. mdickinson commented on Feb 5, 2023

    @mdickinson
    mdickinson
    on Feb 5, 2023
    Member
    More actions

    I had half a solution to this at one point (the nextafter-based solution looks attractive in principle, but doesn't end up doing the right thing, unfortunately); I can try to pick this up if that's helpful. I'm out of cycles for this weekend, though, so it won't be before next weekend.

  10. gpshead commented on Feb 5, 2023

    @gpshead
    gpshead
    on Feb 5, 2023
    Member
    More actions

    this warning has been around a while, no rush. I just figured you're the best to understand it.

    clang on any platform will reproduce it.

    Reacted by Mark Dickinson
  11. mdickinson
    self-assigned this
    on Feb 5, 2023
  12. gpshead
    added a commit that references this issue on Feb 20, 2023

    gh-97786: Fix compiler warnings in pytime.c (#101826)

    b1b375e
  13. miss-islington
    added a commit that references this issue on Feb 20, 2023

    pythongh-97786: Fix compiler warnings in pytime.c (pythonGH-101826)

    7e25925
  14. jaraco
    added a commit that references this issue on Feb 20, 2023

    pythongh-97786: Fix compiler warnings in pytime.c (python#101826)

    c6f8395
  15. carljm
    added a commit that references this issue on Feb 20, 2023

    Merge branch 'main' into inlinecomp2

    9f0fc5b
  16. mdickinson
    added a commit that references this issue on Feb 22, 2023

    [3.11] gh-97786: Fix compiler warnings in pytime.c (GH-101826) (#102062)

    ddb65c4
  17. carljm
    added a commit that references this issue on Feb 22, 2023

    Merge branch 'main' into inlinecomp

    544b30c
  18. mdickinson
    added a commit that references this issue on Feb 26, 2023

    [3.10] gh-97786: Fix compiler warnings in pytime.c (GH-101826) (#102150)

    5b610b5
  19. arhadthedev commented on Mar 3, 2023

    @arhadthedev
    arhadthedev
    on Mar 3, 2023
    Member
    More actions

    The issue seems to be fixed. Should it be closed then?

    Reacted by Mark Dickinson
  20. brettcannon
    closed this as completedon Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mdickinson
    mdickinson

Labels

3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.