public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115806] New: No error for enum redefinition in template
@ 2024-07-06 14:10 nshead at gcc dot gnu.org
  2024-07-06 15:08 ` [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation) pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-07-06 14:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115806
           Summary: No error for enum redefinition in template
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nshead at gcc dot gnu.org
  Target Milestone: ---

The following code currently compiles with no error:

  template <typename T>
  struct S {
    enum E { a };
    enum E { b };
  };
  S<int> s;

The same code without S being a template correctly errors with:

<source>:3:10: error: multiple definition of 'enum S::E'
    3 |     enum E {b};
      |          ^
<source>:2:10: note: previous definition here
    2 |     enum E {a};
      |          ^

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

* [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
@ 2024-07-06 15:08 ` pinskia at gcc dot gnu.org
  2024-07-07 18:48 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-06 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-07-06
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
  2024-07-06 15:08 ` [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation) pinskia at gcc dot gnu.org
@ 2024-07-07 18:48 ` pinskia at gcc dot gnu.org
  2024-07-19 13:26 ` [Bug c++/115806] [12/13/14/15 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-07 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5

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

* [Bug c++/115806] [12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
  2024-07-06 15:08 ` [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation) pinskia at gcc dot gnu.org
  2024-07-07 18:48 ` pinskia at gcc dot gnu.org
@ 2024-07-19 13:26 ` rguenth at gcc dot gnu.org
  2024-08-08 14:03 ` simartin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-19 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.5                        |12.5

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11 branch is being closed.

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

* [Bug c++/115806] [12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-07-19 13:26 ` [Bug c++/115806] [12/13/14/15 " rguenth at gcc dot gnu.org
@ 2024-08-08 14:03 ` simartin at gcc dot gnu.org
  2024-08-08 14:48 ` simartin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simartin at gcc dot gnu.org @ 2024-08-08 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

Simon Martin <simartin at gcc dot gnu.org> changed:

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

--- Comment #3 from Simon Martin <simartin at gcc dot gnu.org> ---
I'm working on this one.

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

* [Bug c++/115806] [12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-08-08 14:03 ` simartin at gcc dot gnu.org
@ 2024-08-08 14:48 ` simartin at gcc dot gnu.org
  2024-08-09 15:16 ` cvs-commit at gcc dot gnu.org
  2024-08-09 15:18 ` simartin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: simartin at gcc dot gnu.org @ 2024-08-08 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Simon Martin <simartin at gcc dot gnu.org> ---
This started to fail with
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=557831a91df947b447fc9fd94ecad02470a3c86a

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

* [Bug c++/115806] [12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-08-08 14:48 ` simartin at gcc dot gnu.org
@ 2024-08-09 15:16 ` cvs-commit at gcc dot gnu.org
  2024-08-09 15:18 ` simartin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-09 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Martin <simartin@gcc.gnu.org>:

https://gcc.gnu.org/g:786ebbd6058540b2110da16a693f0c582c11413c

commit r15-2855-g786ebbd6058540b2110da16a693f0c582c11413c
Author: Simon Martin <simon@nasilyan.com>
Date:   Thu Aug 8 14:59:49 2024 +0200

    c++: Don't accept multiple enum definitions within template class
[PR115806]

    We have been accepting the following invalid code since revision
557831a91df

    === cut here ===
    template <typename T> struct S {
      enum E { a };
      enum E { b };
    };
    S<int> s;
    === cut here ===

    The problem is that start_enum will set OPAQUE_ENUM_P to true even if it
    retrieves an existing definition for the enum, which causes the
redefinition
    check in cp_parser_enum_specifier to be bypassed.

    This patch only sets OPAQUE_ENUM_P and ENUM_FIXED_UNDERLYING_TYPE_P when
    actually pushing a new tag for the enum.

            PR c++/115806

    gcc/cp/ChangeLog:

            * decl.cc (start_enum): Only set OPAQUE_ENUM_P and
            ENUM_FIXED_UNDERLYING_TYPE_P when pushing a new tag.

    gcc/testsuite/ChangeLog:

            * g++.dg/parse/enum15.C: New test.

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

* [Bug c++/115806] [12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation)
  2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-08-09 15:16 ` cvs-commit at gcc dot gnu.org
@ 2024-08-09 15:18 ` simartin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: simartin at gcc dot gnu.org @ 2024-08-09 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

Simon Martin <simartin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|12.5                        |15.0

--- Comment #6 from Simon Martin <simartin at gcc dot gnu.org> ---
Fixed in trunk.

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

end of thread, other threads:[~2024-08-09 15:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-06 14:10 [Bug c++/115806] New: No error for enum redefinition in template nshead at gcc dot gnu.org
2024-07-06 15:08 ` [Bug c++/115806] [11/12/13/14/15 Regression] No error for member enum redefinition in class template (even after instantiation) pinskia at gcc dot gnu.org
2024-07-07 18:48 ` pinskia at gcc dot gnu.org
2024-07-19 13:26 ` [Bug c++/115806] [12/13/14/15 " rguenth at gcc dot gnu.org
2024-08-08 14:03 ` simartin at gcc dot gnu.org
2024-08-08 14:48 ` simartin at gcc dot gnu.org
2024-08-09 15:16 ` cvs-commit at gcc dot gnu.org
2024-08-09 15:18 ` simartin 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).