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

            Bug ID: 86377
           Summary: extern int errno; is treated as buggy function
                    declaration [-Werror=strict-prototypes]
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: um at mutluit dot com
  Target Milestone: ---

Created attachment 44344
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44344&action=edit
The output file of -save-temps (ie. the "file.i" file)

test file extern_var_bug.c:
----------------- 
#include <errno.h>
extern int errno;

int main(int argc, char* argv[])
{
  return errno;
}


Output:
-------
extern_var_bug.c:2:16: error: function declaration isn't a prototype
[-Werror=strict-prototypes]
 extern int errno;
                ^
extern_var_bug.c: In function 'main':
extern_var_bug.c:4:14: warning: unused parameter 'argc' [-Wunused-parameter]
 int main(int argc, char* argv[])
          ~~~~^~~~
extern_var_bug.c:4:26: warning: unused parameter 'argv' [-Wunused-parameter]
 int main(int argc, char* argv[])
                    ~~~~~~^~~~~~
cc1: all warnings being treated as errors


Compiler and compile command:
-----------------------------
# gcc-latest is v9 from svn trunk on x86_64
$ gcc-latest --version
gcc-latest (GCC) 9.0.0 20180701 (experimental) [trunk revision 262287]
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc-latest -c -DHAVE_CONFIG_H -fopt-info -Wall -Wextra -Werror -Wpedantic
-pedantic -g0 -DNDEBUG -Ofast \
    -I. -I../../gcc_trunk/libiberty/../include  -W -Wall -Wwrite-strings \
    -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE
-fpic \
    \
    -Wno-error=stringop-truncation -Wno-error=unused-parameter \
    \
    -x c \
    -fno-strict-aliasing -fwrapv \
    -save-temps \
    \
    extern_var_bug.c \


Remarks:
--------
- The compile error happens only if <errno.h> was included, and only if
compiled as C.
- The same error originally happened in 
../../gcc_trunk/libiberty/pex-common.c:28:1: error: function declaration isn't
a prototype [-Werror=strict-prototypes]
 extern int errno;
 ^~~~~~
when building with nearly almost all warnings enabled and -g0 -DNDEBUG.

Reply via email to