public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97882] New: Segmentation Fault on improper redeclaration of function
@ 2020-11-17 21:22 jarod.keene at trojans dot dsu.edu
  2020-11-17 22:19 ` [Bug c/97882] [8/9/10/11 Regression] " jsm28 at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jarod.keene at trojans dot dsu.edu @ 2020-11-17 21:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97882
           Summary: Segmentation Fault on improper redeclaration of
                    function
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jarod.keene at trojans dot dsu.edu
  Target Milestone: ---

Created attachment 49579
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49579&action=edit
Save Temps output from code compilation

After fuzzing GCC version 10.2.0 for grammar-based errors we discovered a
segmentation fault flaw within the compiler. This flaw is also none to be
present in GCC versions 7.5.0, 8.3.0, and 9.3.0. Attached is the output from
-save-temps.

GCC Compilation and system options:
Debian 5.8.0
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.0-16'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-10-YRn5ue/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-YRn5ue/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa
--without-cuda-driver --enable-checking=yes,extra,rtl --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu

Compilation Command Line: gcc bug.c

Compilation Error Message:
bug.c: In function ‘x’:
bug.c:4:2: internal compiler error: Segmentation fault
    4 |  const unsigned x() {};
      |  ^~~~~
0xfe8a6f crash_signal
    ../../src/gcc/toplev.c:328
0x7f65d0b7ce2f ???
    ./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xb01de6 must_pass_in_stack_var_size_or_pad(function_arg_info const&)
    ../../src/gcc/calls.c:6216
0x130b3e8 ix86_must_pass_in_stack
    ../../src/gcc/config/i386/i386.c:1458
0x1337b4a classify_argument
    ../../src/gcc/config/i386/i386.c:2065
0x13383ca examine_argument
    ../../src/gcc/config/i386/i386.c:2459
0x1338d31 ix86_return_in_memory
    ../../src/gcc/config/i386/i386.c:3826
0xca98fe aggregate_value_p(tree_node const*, tree_node const*)
    ../../src/gcc/function.c:2111
0xcae74c allocate_struct_function(tree_node*, bool)
    ../../src/gcc/function.c:4814
0x9e9774 store_parm_decls()
    ../../src/gcc/c/c-decl.c:9781
0xa42092 c_parser_declaration_or_fndef
    ../../src/gcc/c/c-parser.c:2466
0xa21fff c_parser_compound_statement_nostart
    ../../src/gcc/c/c-parser.c:5718
0xa40764 c_parser_compound_statement
    ../../src/gcc/c/c-parser.c:5617
0xa42221 c_parser_declaration_or_fndef
    ../../src/gcc/c/c-parser.c:2505
0xa4a393 c_parser_external_declaration
    ../../src/gcc/c/c-parser.c:1745
0xa4ae91 c_parser_translation_unit
    ../../src/gcc/c/c-parser.c:1618
0xa4ae91 c_parse_file()
    ../../src/gcc/c/c-parser.c:21752
0xaa219b c_common_parse_file()
    ../../src/gcc/c-family/c-opts.c:1190

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
@ 2020-11-17 22:19 ` jsm28 at gcc dot gnu.org
  2020-11-18 15:29 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2020-11-17 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-11-17
   Target Milestone|---                         |8.5
             Status|UNCONFIRMED                 |NEW
            Summary|Segmentation Fault on       |[8/9/10/11 Regression]
                   |improper redeclaration of   |Segmentation Fault on
                   |function                    |improper redeclaration of
                   |                            |function
     Ever confirmed|0                           |1

--- Comment #1 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Looks like a regression in GCC 7 relative to GCC 6.  Whether this code is valid
or invalid GNU C is a tricky question, but I'm inclined to say that when the
incomplete enum type extension is used, we should *not* count such enums as
compatible with unsigned int since we don't know what members the enum will
have once completed.  So, for example, I think we ought to reject

extern enum foo *x;
unsigned int *x;

and certainly ought to reject

extern enum foo *x;
unsigned int *x;
enum foo { A = -1 };

where the enum ends up compatible with int rather than unsigned int.  (But a
patch involving rejecting such code might not be such a good idea for
backporting, given the risk of breaking user programs that build OK with the
release branch compilers.)

(A C11 defect fix incorporated in C17 means a qualifier on a function return
type is ignored, so whether the code is valid is not affected by the "const" in
the original test case.)

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
  2020-11-17 22:19 ` [Bug c/97882] [8/9/10/11 Regression] " jsm28 at gcc dot gnu.org
@ 2020-11-18 15:29 ` jakub at gcc dot gnu.org
  2021-01-14  9:41 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r7-760-gaa4b467b680f230ab11922d1e29695e1eaba12af

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
  2020-11-17 22:19 ` [Bug c/97882] [8/9/10/11 Regression] " jsm28 at gcc dot gnu.org
  2020-11-18 15:29 ` jakub at gcc dot gnu.org
@ 2021-01-14  9:41 ` rguenth at gcc dot gnu.org
  2021-02-02 17:06 ` msebor at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  9:41 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (2 preceding siblings ...)
  2021-01-14  9:41 ` rguenth at gcc dot gnu.org
@ 2021-02-02 17:06 ` msebor at gcc dot gnu.org
  2021-02-02 17:41 ` msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-02 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |msebor at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
While testing a fix for this I came up with the following variation on the
original test case:

  void f (void)
  {
    auto enum E g ();   // valid?
    unsigned g () { }
  }

This also ICEs but I'm not sure if it should be fixed the same way as the
original 
 or rather by rejecting the auto storage specifier on nested function
declarations.  Since nested functions are implicitly static the auto is in
conflict with that, the same way extern is below.  Shouldn't the auto be
rejected?  (There are tests that expect this to be valid, e.g.,
gcc.dg/nested-func-3.c.)

$ cat t.c && /build/gcc-trunk/gcc/cc1 t.c
void f (void)
{
  extern enum E g ();
  unsigned g () { }
}

 f g
t.c:4:12: error: static declaration of ‘g’ follows non-static declaration
    4 |   unsigned g () { }
      |            ^
t.c:3:17: note: previous declaration of ‘g’ was here
    3 |   extern enum E g ();
      |                 ^
t.c: In function ‘g’:
t.c:4:3: internal compiler error: Segmentation fault
    4 |   unsigned g () { }
      |   ^~~~~~~~
0x13f321a crash_signal
        /src/gcc/trunk/gcc/toplev.c:327
0xbdc3b4 must_pass_in_stack_var_size_or_pad(function_arg_info const&)
        /src/gcc/trunk/gcc/calls.c:6282

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (3 preceding siblings ...)
  2021-02-02 17:06 ` msebor at gcc dot gnu.org
@ 2021-02-02 17:41 ` msebor at gcc dot gnu.org
  2021-02-03 23:23 ` msebor at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-02 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
A couple of data points: Clang doesn't support nested functions in any form,
and ICC silently all three storage specifiers (auto, extern, as well as static)
on their definitions and rejects only register.

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (4 preceding siblings ...)
  2021-02-02 17:41 ` msebor at gcc dot gnu.org
@ 2021-02-03 23:23 ` msebor at gcc dot gnu.org
  2021-02-04 21:54 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-03 23:23 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code, patch

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564819.html

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (5 preceding siblings ...)
  2021-02-03 23:23 ` msebor at gcc dot gnu.org
@ 2021-02-04 21:54 ` cvs-commit at gcc dot gnu.org
  2021-02-04 21:55 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-04 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:ce5720447c69286599b96bae53ae854b1bbe41fa

commit r11-7107-gce5720447c69286599b96bae53ae854b1bbe41fa
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Feb 4 14:50:23 2021 -0700

    PR c/97882 - Segmentation Fault on improper redeclaration of function

    gcc/c/ChangeLog:

            PR c/97882
            * c-decl.c (locate_old_decl): Add type to diagnostic output.
            (diagnose_mismatched_decls): Same.
            (start_function): Introduce temporaries for better readability.
            * c-typeck.c (comptypes_internal): Only consider complete enum
            types in comparisons with integers.

    gcc/testsuite/ChangeLog:

            PR c/97882
            * gcc.dg/decl-8.c: Adjust text of expected diagnostic.
            * gcc.dg/label-decl-4.c: Same.
            * gcc.dg/mismatch-decl-1.c: Same.
            * gcc.dg/old-style-then-proto-1.c: Same.
            * gcc.dg/parm-mismatch-1.c: Same.
            * gcc.dg/pr35445.c: Same.
            * gcc.dg/redecl-11.c: Same.
            * gcc.dg/redecl-12.c: Same.
            * gcc.dg/redecl-13.c: Same.
            * gcc.dg/redecl-15.c: Same.
            * gcc.dg/tls/thr-init-1.c: Same.
            * objc.dg/id-1.m: Same.
            * objc.dg/tls/diag-3.m: Same.
            * gcc.dg/pr97882.c: New test.
            * gcc.dg/qual-return-7.c: New test.
            * gcc.dg/qual-return-8.c: New test.

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (6 preceding siblings ...)
  2021-02-04 21:54 ` cvs-commit at gcc dot gnu.org
@ 2021-02-04 21:55 ` msebor at gcc dot gnu.org
  2021-07-29 17:13 ` pinskia at gcc dot gnu.org
  2021-07-29 17:16 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-04 21:55 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to fail|                            |10.2.0, 7.3.0, 8.3.0, 9.2.0
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|8.5                         |11.0

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed.  Will not backport per comment 1.

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (7 preceding siblings ...)
  2021-02-04 21:55 ` msebor at gcc dot gnu.org
@ 2021-07-29 17:13 ` pinskia at gcc dot gnu.org
  2021-07-29 17:16 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-29 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dpotapov at gmail dot com

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 92428 has been marked as a duplicate of this bug. ***

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

* [Bug c/97882] [8/9/10/11 Regression] Segmentation Fault on improper redeclaration of function
  2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
                   ` (8 preceding siblings ...)
  2021-07-29 17:13 ` pinskia at gcc dot gnu.org
@ 2021-07-29 17:16 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-29 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gscfq@t-online.de

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 89932 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-07-29 17:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 21:22 [Bug c/97882] New: Segmentation Fault on improper redeclaration of function jarod.keene at trojans dot dsu.edu
2020-11-17 22:19 ` [Bug c/97882] [8/9/10/11 Regression] " jsm28 at gcc dot gnu.org
2020-11-18 15:29 ` jakub at gcc dot gnu.org
2021-01-14  9:41 ` rguenth at gcc dot gnu.org
2021-02-02 17:06 ` msebor at gcc dot gnu.org
2021-02-02 17:41 ` msebor at gcc dot gnu.org
2021-02-03 23:23 ` msebor at gcc dot gnu.org
2021-02-04 21:54 ` cvs-commit at gcc dot gnu.org
2021-02-04 21:55 ` msebor at gcc dot gnu.org
2021-07-29 17:13 ` pinskia at gcc dot gnu.org
2021-07-29 17:16 ` 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).