Skip to content
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

BUG: fix issue with broken assert statement in templ_common.h.src #22576

Merged
merged 1 commit into from
Nov 12, 2022

Conversation

rgommers
Copy link
Member

assert() only takes one argument. This was recently introduced, in commit 4156ae2 (gh-21793).

It looks like this code is not exercised in CI. I only stumbled over it because I'm working with an incomplete config header, so HAVE___BUILTIN_MUL_OVERFLOW was not defined.

Full error:

In file included from ../numpy/core/src/common/npy_hashtable.c:15:
../numpy/core/src/common/templ_common.h.src: In function 'npy_mul_sizes_with_overflow':
../numpy/core/src/common/templ_common.h.src:61:80: error: macro "assert" passed 2 arguments, but takes just 1
   61 |     assert(a >= 0 && b >= 0, "this function only supports non-negative numbers");
      |                                                                                ^
In file included from /home/rgommers/mambaforge/envs/numpy-dev/include/python3.9/Python.h:48,
                 from ../numpy/core/include/numpy/npy_common.h:5,
                 from ../numpy/core/src/common/templ_common.h.src:6,
                 from ../numpy/core/src/common/npy_hashtable.c:15:
/home/rgommers/mambaforge/envs/numpy-dev/x86_64-conda-linux-gnu/sysroot/usr/include/assert.h:52: note: macro "assert" defined here
   52 | # define assert(expr)  (__ASSERT_VOID_CAST (0))
      | 
In file included from ../numpy/core/src/common/npy_hashtable.c:15:
../numpy/core/src/common/templ_common.h.src:61:5: error: 'assert' undeclared (first use in this function)
   61 |     assert(a >= 0 && b >= 0, "this function only supports non-negative numbers");
      |     ^~~~~~
In file included from ../numpy/core/src/common/npy_hashtable.c:15:
../numpy/core/src/common/templ_common.h.src:7:1: note: 'assert' is defined in header '<assert.h>'; did you forget to '#include <assert.h>'?
    6 | #include "numpy/npy_common.h"
  +++ |+#include <assert.h>
    7 | 
In file included from ../numpy/core/src/common/npy_hashtable.c:15:
../numpy/core/src/common/templ_common.h.src:61:5: note: each undeclared identifier is reported only once for each function it appears in
   61 |     assert(a >= 0 && b >= 0, "this function only supports non-negative numbers");
      |     ^~~~~~

assert() only takes one argument.
This was recently introduced, in commit 4156ae2 (numpygh-21793)
@charris
Copy link
Member

charris commented Nov 12, 2022

I'm just going to put this in. Thanks Ralf.

@rgommers rgommers deleted the fix-assert branch November 12, 2022 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants