Skip to content

GCC 15 warnings: destination lacks 'nonstring' attribute #133256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vstinner opened this issue May 1, 2025 · 0 comments
Closed

GCC 15 warnings: destination lacks 'nonstring' attribute #133256

vstinner opened this issue May 1, 2025 · 0 comments

Comments

@vstinner
Copy link
Member

vstinner commented May 1, 2025

Building Python 3.14 (main branch) with GCC 15 (on Fedora 42) emits the following compiler warnings:

In file included from ./Include/internal/pycore_runtime_structs.h:68,
                 from ./Include/internal/pycore_runtime.h:11,
                 from ./Include/internal/pycore_object.h:15,
                 from ./Include/internal/pycore_dict.h:11,
                 from Python/pylifecycle.c:9:
./Include/internal/pycore_debug_offsets.h:12:26: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization]
   12 | #define _Py_Debug_Cookie "xdebugpy"
      |                          ^~~~~~~~~~
./Include/internal/pycore_debug_offsets.h:225:15: note: in definition of macro '_Py_DebugOffsets_INIT'
  225 |     .cookie = debug_cookie, \
      |               ^~~~~~~~~~~~
Python/pylifecycle.c:114:3: note: in expansion of macro '_PyRuntimeState_INIT'
  114 | = _PyRuntimeState_INIT(_PyRuntime, _Py_Debug_Cookie);
      |   ^~~~~~~~~~~~~~~~~~~~
Python/pylifecycle.c:114:36: note: in expansion of macro '_Py_Debug_Cookie'
  114 | = _PyRuntimeState_INIT(_PyRuntime, _Py_Debug_Cookie);
      |                                    ^~~~~~~~~~~~~~~~


./Modules/fcntlmodule.c:27:36: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization]
   27 | static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue May 1, 2025
Fix GCC 15 compiler warnings such as:

    Modules/fcntlmodule.c:27:36: warning: initializer-string for
    array of 'char' truncates NUL terminator but destination lacks
    'nonstring' attribute (9 chars into 8 available)
    [-Wunterminated-string-initialization]
    static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
vstinner added a commit to vstinner/cpython that referenced this issue May 1, 2025
Fix GCC 15 compiler warnings such as:

    Modules/fcntlmodule.c:27:36: warning: initializer-string for
    array of 'char' truncates NUL terminator but destination lacks
    'nonstring' attribute (9 chars into 8 available)
    [-Wunterminated-string-initialization]
    static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
vstinner added a commit that referenced this issue May 1, 2025
Fix GCC 15 compiler warnings such as:

    Modules/fcntlmodule.c:27:36: warning: initializer-string for
    array of 'char' truncates NUL terminator but destination lacks
    'nonstring' attribute (9 chars into 8 available)
    [-Wunterminated-string-initialization]
    static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
@vstinner vstinner closed this as completed May 1, 2025
vstinner added a commit to vstinner/cpython that referenced this issue Jun 4, 2025
Fix GCC 15 compiler warnings such as:

    In file included from Python/pylifecycle.c:26:
    Include/internal/pycore_runtime.h:47:26: warning:
    initializer-string for array of 'char' truncates NUL terminator
    but destination lacks 'nonstring' attribute (9 chars into 8
    available) [-Wunterminated-string-initialization]
       47 | #define _Py_Debug_Cookie "xdebugpy"
          |                          ^~~~~~~~~~

(cherry picked from commit e26bafd)
vstinner added a commit that referenced this issue Jun 4, 2025
gh-133256: Add _Py_NONSTRING macro (#133257)

Fix GCC 15 compiler warnings such as:

    In file included from Python/pylifecycle.c:26:
    Include/internal/pycore_runtime.h:47:26: warning:
    initializer-string for array of 'char' truncates NUL terminator
    but destination lacks 'nonstring' attribute (9 chars into 8
    available) [-Wunterminated-string-initialization]
       47 | #define _Py_Debug_Cookie "xdebugpy"
          |                          ^~~~~~~~~~

(cherry picked from commit e26bafd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant