Skip to content

-Wdiscarded-qualifiers warning in _ctypes_test.c my_strchr() under FORTIFY_SOURCE=3 #149707

@utkonos

Description

@utkonos

Bug report

Bug description:

Building 3.14.5 with gcc 15.2 and --enable-slower-safety produces this warning:

    default: ./Modules/_ctypes/_ctypes_test.c: In function ‘my_strchr’:
    default: ./Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    default:   451 |     return strchr(s, c);
    default:       |            ^~~~~~

Build environment: Ubuntu 26.04 LTS, gcc 15.2.0, configure with:

./configure --enable-optimizations --with-lto --enable-bolt --enable-safety --enable-slower-safety --with-system-expat CXX=/usr/bin/g++ CFLAGS="-flto=auto" LDFLAGS="-flto=auto"

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildextension-modulesC modules in the Modules dirtestsTests in the Lib/test dirtopic-ctypestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions