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 warnings on string comparisons in _testcapi · Issue #109469 · python/cpython

Compiler warnings on string comparisons in _testcapi #109469

New issue
Copy link
New issue
Copy link
Closed
#109558
Closed
Compiler warnings on string comparisons in _testcapi#109469
#109558
Copy link
Labels
buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtestsTests in the Lib/test dirTests in the Lib/test dir

Description

@iritkatriel
iritkatriel
opened on Sep 15, 2023
Issue body actions
./Modules/_testcapimodule.c:226:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
        assert(v != UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
./Modules/_testcapimodule.c:238:14: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(k == UNINITIALIZED_PTR);
             ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
./Modules/_testcapimodule.c:239:14: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(v == UNINITIALIZED_PTR);
             ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
4 warnings generated.
./Modules/_testcapi/dict.c:289:16: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(key == UNINITIALIZED_PTR);
               ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
./Modules/_testcapi/dict.c:290:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(value == UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
2 warnings generated.
./Modules/_testcapi/exceptions.c:129:17: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(type != UNINITIALIZED_PTR);
                ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
./Modules/_testcapi/exceptions.c:130:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(value != UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
./Modules/_testcapi/exceptions.c:131:15: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(tb != UNINITIALIZED_PTR);
              ^  ~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)

Linked PRs

  • gh-109469: Silence compiler warnings on string comparisons in _testcapi #109533
  • [3.12] gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) #109558
Reacted by sunmy2019

Activity

  1. iritkatriel
    added
    buildThe build process and cross-buildThe build process and cross-build
    testsTests in the Lib/test dirTests in the Lib/test dir
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Sep 15, 2023
  2. sunmy2019 commented on Sep 16, 2023

    @sunmy2019
    sunmy2019
    on Sep 16, 2023
    Member
    More actions

    Changing UNINITIALIZED_PTR to an invalid address literal should resolve this.

    such as #define UNINITIALIZED_PTR 0xcdcdcdcdcdcdcdcd on x64.

  3. erlend-aasland commented on Sep 18, 2023

    @erlend-aasland
    erlend-aasland
    on Sep 18, 2023
    Contributor
    More actions

    cc. @serhiy-storchaka

  4. serhiy-storchaka commented on Sep 18, 2023

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 18, 2023
    Member
    More actions

    The point was to use valid address. On some platforms, not all bit combinations can be interpreted as address, and interpreting them as address can even lead to crash.

    Does the following change help with warning?

    -#define UNINITIALIZED_PTR ((void *)"uninitialized")
    +static const char uninitialized[] = "uninitialized";
    +#define UNINITIALIZED_PTR ((void *)uninitialized)
  5. iritkatriel commented on Sep 18, 2023

    @iritkatriel
    iritkatriel
    on Sep 18, 2023
    MemberAuthor
    More actions

    Does the following change help with warning?

    -#define UNINITIALIZED_PTR ((void *)"uninitialized")
    +static const char uninitialized[] = "uninitialized";
    +#define UNINITIALIZED_PTR ((void *)uninitialized)

    Yes.

  6. serhiy-storchaka
    added 2 commits that reference this issue on Sep 18, 2023

    pythongh-109469: Silence compiler warnings on string comparisons in _…

    d9a9a25

    gh-109469: Silence compiler warnings on string comparisons in _testca…

    ed582a2
  7. miss-islington
    added a commit that references this issue on Sep 19, 2023

    pythongh-109469: Silence compiler warnings on string comparisons in _…

    c8b67c3
  8. serhiy-storchaka
    linked a pull request that will close this issue[3.12] gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) #109558on Sep 20, 2023
  9. csm10495
    added a commit that references this issue on Sep 28, 2023

    pythongh-109469: Silence compiler warnings on string comparisons in _…

    3eb65fb
  10. Yhg1s
    added a commit that references this issue on Oct 2, 2023

    [3.12] gh-109469: Silence compiler warnings on string comparisons in …

    ddc0adc
  11. hugovk commented on Nov 9, 2023

    @hugovk
    hugovk
    on Nov 9, 2023
    Member
    More actions

    Thanks for the fixes!

  12. hugovk
    closed this as completedon Nov 9, 2023
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

    buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtestsTests in the Lib/test dirTests in the Lib/test dir

    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.