public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization
@ 2022-01-25 15:45 ppalka at gcc dot gnu.org
  2022-01-25 15:48 ` [Bug c++/104225] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-25 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104225
           Summary: accepts-invalid new expression that uses deleted
                    implicit default constructor of class specialization
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

The following testcase compiles without error, but should be rejected because
it uses B's deleted default constructor:

class A { ~A(); };
template <class> class B { A f = 1; };
int main() {
  new B<int>;
}

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

* [Bug c++/104225] [9/10/11/12 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
@ 2022-01-25 15:48 ` ppalka at gcc dot gnu.org
  2022-01-25 20:05 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-25 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-25
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org
      Known to work|                            |8.5.0
            Summary|accepts-invalid new         |[9/10/11/12 Regression]
                   |expression that uses        |accepts-invalid new
                   |deleted implicit default    |expression that uses
                   |constructor of class        |deleted implicit default
                   |specialization              |constructor of class
                   |                            |specialization
             Status|UNCONFIRMED                 |NEW
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=101532
   Target Milestone|---                         |9.5
           Keywords|                            |accepts-invalid
      Known to fail|                            |10.3.0, 11.2.0, 12.0, 9.4.0

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r9-6097.

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

* [Bug c++/104225] [9/10/11/12 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
  2022-01-25 15:48 ` [Bug c++/104225] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
@ 2022-01-25 20:05 ` cvs-commit at gcc dot gnu.org
  2022-01-25 20:06 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-25 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

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

commit r12-6863-gbc90dd0ecf02e11d47d1af7f627e2e2acaa40106
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jan 25 15:04:49 2022 -0500

    c++: deleted fn and noexcept inst [PR101532, PR104225]

    Here when attempting to use B's implicitly deleted default constructor,
    mark_used rightfully returns false, but for the wrong reason: it
    tries to instantiate the synthesized noexcept specifier which then only
    silently fails because get_defaulted_eh_spec suppresses diagnostics
    for deleted functions.  This lack of diagnostics causes us to crash on
    the first testcase below (thanks to the assert in finish_expr_stmt), and
    silently accept the second testcase.

    To fix this, this patch makes mark_used avoid attempting to instantiate
    the noexcept specifier of a deleted function, so that we'll instead
    directly reject (and diagnose) the function due to its deletedness.

            PR c++/101532
            PR c++/104225

    gcc/cp/ChangeLog:

            * decl2.cc (mark_used): Don't consider maybe_instantiate_noexcept
            on a deleted function.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/nsdmi-template21.C: New test.
            * g++.dg/cpp0x/nsdmi-template21a.C: New test.

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

* [Bug c++/104225] [9/10/11/12 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
  2022-01-25 15:48 ` [Bug c++/104225] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
  2022-01-25 20:05 ` cvs-commit at gcc dot gnu.org
@ 2022-01-25 20:06 ` ppalka at gcc dot gnu.org
  2022-01-25 20:07 ` [Bug c++/104225] [9/10/11 " ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-25 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed.

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

* [Bug c++/104225] [9/10/11 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-01-25 20:06 ` ppalka at gcc dot gnu.org
@ 2022-01-25 20:07 ` ppalka at gcc dot gnu.org
  2022-01-26  7:33 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-25 20:07 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression]
                   |accepts-invalid new         |accepts-invalid new
                   |expression that uses        |expression that uses
                   |deleted implicit default    |deleted implicit default
                   |constructor of class        |constructor of class
                   |specialization              |specialization
         Resolution|FIXED                       |---

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #3)
> Fixed.

... for GCC 12 so far.

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

* [Bug c++/104225] [9/10/11 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-01-25 20:07 ` [Bug c++/104225] [9/10/11 " ppalka at gcc dot gnu.org
@ 2022-01-26  7:33 ` rguenth at gcc dot gnu.org
  2022-04-12 23:44 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-26  7:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.0
      Known to fail|12.0                        |
           Priority|P3                          |P2

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

* [Bug c++/104225] [9/10/11 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-01-26  7:33 ` rguenth at gcc dot gnu.org
@ 2022-04-12 23:44 ` cvs-commit at gcc dot gnu.org
  2022-05-09 23:32 ` [Bug c++/104225] [9/10 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-12 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:1429db66619d2b801ac0b586b5eed74ab54a35b0

commit r11-9840-g1429db66619d2b801ac0b586b5eed74ab54a35b0
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jan 25 15:04:49 2022 -0500

    c++: deleted fn and noexcept inst [PR101532, PR104225]

    Here when attempting to use B's implicitly deleted default constructor,
    mark_used rightfully returns false, but for the wrong reason: it
    tries to instantiate the synthesized noexcept specifier which then only
    silently fails because get_defaulted_eh_spec suppresses diagnostics
    for deleted functions.  This lack of diagnostics causes us to crash on
    the first testcase below (thanks to the assert in finish_expr_stmt), and
    silently accept the second testcase.

    To fix this, this patch makes mark_used avoid attempting to instantiate
    the noexcept specifier of a deleted function, so that we'll instead
    directly reject (and diagnose) the function due to its deletedness.

            PR c++/101532
            PR c++/104225

    gcc/cp/ChangeLog:

            * decl2.c (mark_used): Don't consider maybe_instantiate_noexcept
            on a deleted function.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/nsdmi-template21.C: New test.
            * g++.dg/cpp0x/nsdmi-template21a.C: New test.

    (cherry picked from commit bc90dd0ecf02e11d47d1af7f627e2e2acaa40106)

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

* [Bug c++/104225] [9/10 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-04-12 23:44 ` cvs-commit at gcc dot gnu.org
@ 2022-05-09 23:32 ` cvs-commit at gcc dot gnu.org
  2022-05-11 14:59 ` [Bug c++/104225] [9 " cvs-commit at gcc dot gnu.org
  2022-05-11 15:05 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-09 23:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

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

commit r10-10602-gad0398474aff6bb7726e9117711b0a111a4b69e7
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jan 25 15:04:49 2022 -0500

    c++: deleted fn and noexcept inst [PR101532, PR104225]

    Here when attempting to use B's implicitly deleted default constructor,
    mark_used rightfully returns false, but for the wrong reason: it
    tries to instantiate the synthesized noexcept specifier which then only
    silently fails because get_defaulted_eh_spec suppresses diagnostics
    for deleted functions.  This lack of diagnostics causes us to crash on
    the first testcase below (thanks to the assert in finish_expr_stmt), and
    silently accept the second testcase.

    To fix this, this patch makes mark_used avoid attempting to instantiate
    the noexcept specifier of a deleted function, so that we'll instead
    directly reject (and diagnose) the function due to its deletedness.

            PR c++/101532
            PR c++/104225

    gcc/cp/ChangeLog:

            * decl2.c (mark_used): Don't consider maybe_instantiate_noexcept
            on a deleted function.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/nsdmi-template21.C: New test.
            * g++.dg/cpp0x/nsdmi-template21a.C: New test.

    (cherry picked from commit bc90dd0ecf02e11d47d1af7f627e2e2acaa40106)

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

* [Bug c++/104225] [9 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-05-09 23:32 ` [Bug c++/104225] [9/10 " cvs-commit at gcc dot gnu.org
@ 2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
  2022-05-11 15:05 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:4df77364f7fd9ce88c012843fff124346e4d3c06

commit r9-10155-g4df77364f7fd9ce88c012843fff124346e4d3c06
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jan 25 15:04:49 2022 -0500

    c++: deleted fn and noexcept inst [PR101532, PR104225]

    Here when attempting to use B's implicitly deleted default constructor,
    mark_used rightfully returns false, but for the wrong reason: it
    tries to instantiate the synthesized noexcept specifier which then only
    silently fails because get_defaulted_eh_spec suppresses diagnostics
    for deleted functions.  This lack of diagnostics causes us to crash on
    the first testcase below (thanks to the assert in finish_expr_stmt), and
    silently accept the second testcase.

    To fix this, this patch makes mark_used avoid attempting to instantiate
    the noexcept specifier of a deleted function, so that we'll instead
    directly reject (and diagnose) the function due to its deletedness.

            PR c++/101532
            PR c++/104225

    gcc/cp/ChangeLog:

            * decl2.c (mark_used): Don't consider maybe_instantiate_noexcept
            on a deleted function.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/nsdmi-template21.C: New test.
            * g++.dg/cpp0x/nsdmi-template21a.C: New test.

    (cherry picked from commit bc90dd0ecf02e11d47d1af7f627e2e2acaa40106)

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

* [Bug c++/104225] [9 Regression] accepts-invalid new expression that uses deleted implicit default constructor of class specialization
  2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-05-11 14:59 ` [Bug c++/104225] [9 " cvs-commit at gcc dot gnu.org
@ 2022-05-11 15:05 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-11 15:05 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.3/12.

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

end of thread, other threads:[~2022-05-11 15:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 15:45 [Bug c++/104225] New: accepts-invalid new expression that uses deleted implicit default constructor of class specialization ppalka at gcc dot gnu.org
2022-01-25 15:48 ` [Bug c++/104225] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
2022-01-25 20:05 ` cvs-commit at gcc dot gnu.org
2022-01-25 20:06 ` ppalka at gcc dot gnu.org
2022-01-25 20:07 ` [Bug c++/104225] [9/10/11 " ppalka at gcc dot gnu.org
2022-01-26  7:33 ` rguenth at gcc dot gnu.org
2022-04-12 23:44 ` cvs-commit at gcc dot gnu.org
2022-05-09 23:32 ` [Bug c++/104225] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-11 14:59 ` [Bug c++/104225] [9 " cvs-commit at gcc dot gnu.org
2022-05-11 15:05 ` ppalka 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).