https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100671
Bug ID: 100671
Summary: override-init suppressed in 'two shot' compilation
when initializer macro/value is defined in system
header file
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jan.smets at nokia dot com
Target Milestone: ---
This test case reports a override-init error when doing a "one step"
compilation.
A "two shot" (preprocesing + compilation, eg, what distcc does) reports no
error when the initializer (macro) value is defined in a system header file.
I don't know if this is related, but the diagnostics point towards the value
and not the duplicate index.
#if 1
/* NULL defined in a system header file
=> warning in "one shot" compilation.
=> no warning in "two shot" compilation. */
#include <stddef.h>
#else
/* always warns */
#define NULL (0L)
#endif
void*table[] =
{
[0] NULL,
[0] NULL,
};
echo "One shot"
gcc -c test.c -Woverride-init -o /dev/null
echo "Two shot"
gcc -c test.c -Woverride-init -o test.i -E
gcc -c test.i -o /dev/null -Woverride-init