https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85182
Adam Jackson <ajax at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #3 from Adam Jackson <ajax at redhat dot com> --- (In reply to jos...@codesourcery.com from comment #1) > This is how static assertions are defined in C11, not a bug in GCC: it's a > constraint violation if the constant expression compares equal to 0, > regardless of the context in which the declaration appears (thus, a > constraint violation in a function that is never called, for example). You missed my point. The diagnostic points me to the site of the declaration of the static inline, not of the call site. Let's make this more explicit: --- desoxy:~/git/junkdrawer% cat -n static-assert.h 1 static inline void bar(void) 2 { 3 const int y = 0; 4 _Static_assert(y, "called bar()"); 5 } desoxy:~/git/junkdrawer% cat -n static-assert.c 1 #include "static-assert.h" 2 void foo(void) { bar(); } desoxy:~/git/junkdrawer% gcc -O2 -c static-assert.c In file included from static-assert.c:1: static-assert.h: In function ‘bar’: static-assert.h:4:5: error: static assertion failed: "called bar()" _Static_assert(y, "called bar()"); ^~~~~~~~~~~~~~ --- Don't tell me "in file A included from this spot in B, you hit a static assert". Tell me "At this spot in A, this function defined in B hit a static assert". Because otherwise, with a less trivial assertion, I am going to have _no idea_ where the constraint was violated.