public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute
@ 2024-04-08  9:25 iamanonymous.cs at gmail dot com
  2024-04-08  9:31 ` [Bug c++/114634] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2024-04-08  9:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114634
           Summary: Crash Issue Encountered in GCC Compilation of Template
                    Code with Aligned Attribute
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

The following code snippet triggers a crash issue:

============================================
$ cat bug.cc

template <class> class A
{ enum { e __attribute__ ((aligned(16))) }; };

============================================

The error output is:
============================================
$ gcc bug.cc

internal compiler error: Segmentation fault
    2 | { enum { e __attribute__ ((aligned(16))) }; };
      |                                        ^
0xedc273 crash_signal
        ../../gcc/toplev.cc:319
0x957dd7 diag_attr_exclusions
        ../../gcc/attribs.cc:471
0x95a5f7 decl_attributes(tree_node**, tree_node*, int, tree_node*)
        ../../gcc/attribs.cc:867
0x7ecc0e cplus_decl_attributes(tree_node**, tree_node*, int)
        ../../gcc/cp/decl2.cc:1880
0x7de1d1 build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int)
        ../../gcc/cp/decl.cc:17543
0x890bdc cp_parser_enumerator_definition
        ../../gcc/cp/parser.cc:21903
0x890bdc cp_parser_enumerator_list
        ../../gcc/cp/parser.cc:21823
0x890bdc cp_parser_enum_specifier
        ../../gcc/cp/parser.cc:21754
0x890bdc cp_parser_type_specifier
        ../../gcc/cp/parser.cc:20034
0x8916f1 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.cc:16590
0x8bfc4f cp_parser_member_declaration
        ../../gcc/cp/parser.cc:27984
0x88dec1 cp_parser_member_specification_opt
        ../../gcc/cp/parser.cc:27840
0x88dec1 cp_parser_class_specifier
        ../../gcc/cp/parser.cc:26845
0x890171 cp_parser_type_specifier
        ../../gcc/cp/parser.cc:20064
0x8916f1 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.cc:16590
0x8bd774 cp_parser_single_declaration
        ../../gcc/cp/parser.cc:33143
0x8bdbd3 cp_parser_template_declaration_after_parameters
        ../../gcc/cp/parser.cc:32799
0x8be4b9 cp_parser_explicit_template_declaration
        ../../gcc/cp/parser.cc:33072
0x8be4b9 cp_parser_template_declaration_after_export
        ../../gcc/cp/parser.cc:33091
0x8c1fad cp_parser_declaration
        ../../gcc/cp/parser.cc:15502
============================================

The GCC version:
============================================
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/cTest/gcc/myinstall/libexec/gcc/x86_64-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure -v --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-checking=no
--enable-languages=c,c++ --disable-multilib --prefix=/home/cTest/gcc/myinstall
--disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240329 (experimental) (GCC) 
============================================

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

* [Bug c++/114634] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
@ 2024-04-08  9:31 ` rguenth at gcc dot gnu.org
  2024-04-08 19:22 ` [Bug c++/114634] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-08  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-08
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
          Component|c                           |c++
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Seems when we call this 'e' doesn't have a type and we crash:

  if (DECL_P (node))
    {
      attrs[0] = DECL_ATTRIBUTES (node);
      attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node));

I suppose

  if ((code == FUNCTION_DECL && !excl->function
       && (!excl->type || !spec->affects_type_identity))
      || (code == VAR_DECL && !excl->variable
          && (!excl->type || !spec->affects_type_identity))
      || (((code == TYPE_DECL || RECORD_OR_UNION_TYPE_P (node)) &&
!excl->type)))
    return false;

could add || (code != FUNCTION_DECL && code != VAR_DECL && code != TYPE_DECL)

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

* [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
  2024-04-08  9:31 ` [Bug c++/114634] " rguenth at gcc dot gnu.org
@ 2024-04-08 19:22 ` pinskia at gcc dot gnu.org
  2024-04-12 13:33 ` law at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-08 19:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |8.5.0
   Target Milestone|---                         |11.5
            Summary|Crash Issue Encountered in  |[11/12/13/14 Regression]
                   |GCC Compilation of Template |Crash Issue Encountered in
                   |Code with Aligned Attribute |GCC Compilation of Template
                   |                            |Code with Aligned Attribute
           Keywords|ice-on-valid-code           |ice-on-invalid-code
      Known to fail|                            |9.1.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So GCC 8.5.0 and before we rejected this code:
```
<source>:5:10: error: alignment may not be specified for 'e'
   enum { e __attribute__ ((aligned(16))) };
          ^
```


And GCC trunk rejects it if not inside a template struct so changing
ice-on-valid to ice-on-invalid and marking it as a regression.


Note clang accepts it in both cases though. But this is a gcc extension after
all.

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

* [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
  2024-04-08  9:31 ` [Bug c++/114634] " rguenth at gcc dot gnu.org
  2024-04-08 19:22 ` [Bug c++/114634] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-04-12 13:33 ` law at gcc dot gnu.org
  2024-04-12 14:01 ` [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745 jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2024-04-12 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |law at gcc dot gnu.org

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

* [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
                   ` (2 preceding siblings ...)
  2024-04-12 13:33 ` law at gcc dot gnu.org
@ 2024-04-12 14:01 ` jakub at gcc dot gnu.org
  2024-04-12 16:34 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-12 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 Regression]    |[11/12/13/14 Regression]
                   |Crash Issue Encountered in  |Crash Issue Encountered in
                   |GCC Compilation of Template |GCC Compilation of Template
                   |Code with Aligned Attribute |Code with Aligned Attribute
                   |                            |since r9-1745
                 CC|                            |jakub at gcc dot gnu.org
           Priority|P1                          |P2

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r9-1745-gbffc62707f731f20ded6993e734a361945684955
I don't think 5+ years old ice-on-invalid-code should be P1.

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

* [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
                   ` (3 preceding siblings ...)
  2024-04-12 14:01 ` [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745 jakub at gcc dot gnu.org
@ 2024-04-12 16:34 ` jakub at gcc dot gnu.org
  2024-04-17 12:56 ` [Bug c++/114634] [11/12/13 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-12 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57936
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57936&action=edit
gcc14-pr114634.patch

Untested fix.

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

* [Bug c++/114634] [11/12/13 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
                   ` (4 preceding siblings ...)
  2024-04-12 16:34 ` jakub at gcc dot gnu.org
@ 2024-04-17 12:56 ` jakub at gcc dot gnu.org
  2024-04-21  4:09 ` cvs-commit at gcc dot gnu.org
  2024-04-23  6:44 ` [Bug c++/114634] [11/12 " jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-17 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 Regression]    |[11/12/13 Regression] Crash
                   |Crash Issue Encountered in  |Issue Encountered in GCC
                   |GCC Compilation of Template |Compilation of Template
                   |Code with Aligned Attribute |Code with Aligned Attribute
                   |since r9-1745               |since r9-1745

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
commit r14-9962-g7ec54f5fdfec298812a749699874db4d6a7246bb                       
Author: Jakub Jelinek <jakub@redhat.com>                                        
Date:   Mon Apr 15 10:25:22 2024 +0200                                          

    attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]   

    The enumerator still doesn't have TREE_TYPE set but diag_attr_exclusions    
    assumes that all decls must have types.                                     
    I think it is better in something as unimportant as diag_attr_exclusions    
    to be more robust, if there is no type, it can just diagnose exclusions     
    on the DECL_ATTRIBUTES, like for types it only diagnoses it on              
    TYPE_ATTRIBUTES.                                                            

    2024-04-15  Jakub Jelinek  <jakub@redhat.com>                               

            PR c++/114634                                                       
            * attribs.cc (diag_attr_exclusions): Set attrs[1] to NULL_TREE for  
            decls with NULL TREE_TYPE.                                          

            * g++.dg/ext/attrib68.C: New test.

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

* [Bug c++/114634] [11/12/13 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
                   ` (5 preceding siblings ...)
  2024-04-17 12:56 ` [Bug c++/114634] [11/12/13 " jakub at gcc dot gnu.org
@ 2024-04-21  4:09 ` cvs-commit at gcc dot gnu.org
  2024-04-23  6:44 ` [Bug c++/114634] [11/12 " jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-21  4:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:2c85e8def0efd4b0d9d312a1f0cbbee332b4e0d1

commit r13-8633-g2c85e8def0efd4b0d9d312a1f0cbbee332b4e0d1
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Apr 15 10:25:22 2024 +0200

    attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]

    The enumerator still doesn't have TREE_TYPE set but diag_attr_exclusions
    assumes that all decls must have types.
    I think it is better in something as unimportant as diag_attr_exclusions
    to be more robust, if there is no type, it can just diagnose exclusions
    on the DECL_ATTRIBUTES, like for types it only diagnoses it on
    TYPE_ATTRIBUTES.

    2024-04-15  Jakub Jelinek  <jakub@redhat.com>

            PR c++/114634
            * attribs.cc (diag_attr_exclusions): Set attrs[1] to NULL_TREE for
            decls with NULL TREE_TYPE.

            * g++.dg/ext/attrib68.C: New test.

    (cherry picked from commit 7ec54f5fdfec298812a749699874db4d6a7246bb)

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

* [Bug c++/114634] [11/12 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745
  2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
                   ` (6 preceding siblings ...)
  2024-04-21  4:09 ` cvs-commit at gcc dot gnu.org
@ 2024-04-23  6:44 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-23  6:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13 Regression] Crash |[11/12 Regression] Crash
                   |Issue Encountered in GCC    |Issue Encountered in GCC
                   |Compilation of Template     |Compilation of Template
                   |Code with Aligned Attribute |Code with Aligned Attribute
                   |since r9-1745               |since r9-1745

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 13.3 too.

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

end of thread, other threads:[~2024-04-23  6:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08  9:25 [Bug c/114634] New: Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute iamanonymous.cs at gmail dot com
2024-04-08  9:31 ` [Bug c++/114634] " rguenth at gcc dot gnu.org
2024-04-08 19:22 ` [Bug c++/114634] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-04-12 13:33 ` law at gcc dot gnu.org
2024-04-12 14:01 ` [Bug c++/114634] [11/12/13/14 Regression] Crash Issue Encountered in GCC Compilation of Template Code with Aligned Attribute since r9-1745 jakub at gcc dot gnu.org
2024-04-12 16:34 ` jakub at gcc dot gnu.org
2024-04-17 12:56 ` [Bug c++/114634] [11/12/13 " jakub at gcc dot gnu.org
2024-04-21  4:09 ` cvs-commit at gcc dot gnu.org
2024-04-23  6:44 ` [Bug c++/114634] [11/12 " jakub 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).