public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100671] New: override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file
@ 2021-05-19  8:51 jan.smets at nokia dot com
  2021-05-19  9:14 ` [Bug c/100671] " jan.smets at nokia dot com
  2021-05-19  9:44 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jan.smets at nokia dot com @ 2021-05-19  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/100671] override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file
  2021-05-19  8:51 [Bug c/100671] New: override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file jan.smets at nokia dot com
@ 2021-05-19  9:14 ` jan.smets at nokia dot com
  2021-05-19  9:44 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jan.smets at nokia dot com @ 2021-05-19  9:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100671

--- Comment #1 from Jan Smets <jan.smets at nokia dot com> ---
Another one we've had problems with is quite similar. The example below is a
void function trying to return a value. 

#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 test(void)
{
    return NULL;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/100671] override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file
  2021-05-19  8:51 [Bug c/100671] New: override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file jan.smets at nokia dot com
  2021-05-19  9:14 ` [Bug c/100671] " jan.smets at nokia dot com
@ 2021-05-19  9:44 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-19  9:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100671

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is a dup of bug 99791.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-19  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  8:51 [Bug c/100671] New: override-init suppressed in 'two shot' compilation when initializer macro/value is defined in system header file jan.smets at nokia dot com
2021-05-19  9:14 ` [Bug c/100671] " jan.smets at nokia dot com
2021-05-19  9:44 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).