https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45840
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2016-05-02 Ever confirmed|0 |1 Known to fail| |4.9.3, 5.3.0, 6.0 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed with today's top of trunk (see the simple test case below). I think a warning should (might?) be doable. Since in both C and C++ a function that takes a pointer to an array of constant size can be passed a pointer to an array of a different size (in C++ this requires a cast) it's an open question whether this case should also trigger an abort at runtime. $ cat v.c && /home/msebor/build/gcc-trunk-git/gcc/xgcc -B/home/msebor/build/gcc-trunk-git/gcc -O2 -Wall -Wextra -Wpedantic v.c && ./a.out inline void __attribute__ ((always_inline)) f (int (*pa)[3]) { __builtin_printf ("%s: %zd\n", __func__, __builtin_object_size (*pa, 0)); } void __attribute__ ((noclone, noinline)) g (int (*pa)[3]) { __builtin_printf ("%s: %zd\n", __func__, __builtin_object_size (*pa, 0)); } int main () { int a [3]; int (*pa)[3] = &a; __builtin_printf ("%s: %zd\n", __func__, __builtin_object_size (*pa, 0)); f (pa); g (pa); } main: 12 f: 12 g: -1