Skip to content

Commit 04fcc67

Browse files
committed
Raise Cython enum overflows as compile-time errors
1 parent e96903e commit 04fcc67

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎cuda_bindings_13/_build_shared.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ def _build_flags(name, cxx_std, debug, coverage, warnings_as_errors):
221221
222222
- Linux compile: ``-std=c++{cxx_std}``, then ``-g0 -O2`` (opt) or
223223
``-g -O0 -D _GLIBCXX_ASSERTIONS`` (debug).
224+
- gnu compile: ``-pedantic -Werror=overflow``, which fails the build when a
225+
constant overflows ``int`` (e.g. a 32-bit unsigned value in a Cython enum).
224226
- Linux link: ``-fuse-ld=lld`` (llvm) and ``-Wl,--strip-all`` (opt).
225227
- MSVC compile: ``/std:c++{cxx_std}`` and ``/O2``. Modern setuptools no
226228
longer forces ``/Ox``, so the optimization level is set explicitly for
@@ -239,6 +241,8 @@ def _build_flags(name, cxx_std, debug, coverage, warnings_as_errors):
239241
# Common Linux compile flags.
240242
extra_compile_args += [f"-std=c++{cxx_std}"]
241243
# Compiler-specific flags.
244+
if name == "gnu":
245+
extra_compile_args += ["-pedantic", "-Werror=overflow"]
242246
if name == "llvm":
243247
extra_link_args += ["-fuse-ld=lld"]
244248
# Common Linux debug/opt flags.

0 commit comments

Comments
 (0)