public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor
@ 2024-02-13 13:57 ppalka at gcc dot gnu.org
2024-02-13 13:59 ` [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557 ppalka at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-13 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113908
Bug ID: 113908
Summary: [14 Regression] bogus access error with new-expr of
current non-template class with implicitly deleted
copy ctor
Product: gcc
Version: 14.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: ---
struct B {
B() = default;
private:
B(const B&);
};
struct A {
B b;
template<class T>
static void f() { new A(); }
};
int main() {
A::f<int>();
}
<stdin>: In instantiation of ‘static void A::f() [with T = int]’:
<stdin>:15:12: required from here
<stdin>:11:27: error: ‘B::B(const B&)’ is private within this context
<stdin>:4:3: note: declared private here
<stdin>:11:27: error: ‘B::B(const B&)’ is private within this context
<stdin>:4:3: note: declared private here
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557
2024-02-13 13:57 [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor ppalka at gcc dot gnu.org
@ 2024-02-13 13:59 ` ppalka at gcc dot gnu.org
2024-02-13 14:01 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-13 13:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113908
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Target Milestone|--- |14.0
Ever confirmed|0 |1
Last reconfirmed| |2024-02-13
Keywords| |rejects-valid
CC| |jakub at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Summary|[14 Regression] bogus |[14 Regression] bogus
|access error with new-expr |access error with new-expr
|of current non-template |of current non-template
|class with implicitly |class with implicitly
|deleted copy ctor |deleted copy ctor since
| |r14-557
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557
2024-02-13 13:57 [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor ppalka at gcc dot gnu.org
2024-02-13 13:59 ` [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557 ppalka at gcc dot gnu.org
@ 2024-02-13 14:01 ` jakub at gcc dot gnu.org
2024-02-14 15:21 ` cvs-commit at gcc dot gnu.org
2024-02-14 15:22 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-13 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113908
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557
2024-02-13 13:57 [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor ppalka at gcc dot gnu.org
2024-02-13 13:59 ` [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557 ppalka at gcc dot gnu.org
2024-02-13 14:01 ` jakub at gcc dot gnu.org
@ 2024-02-14 15:21 ` cvs-commit at gcc dot gnu.org
2024-02-14 15:22 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-14 15:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113908
--- Comment #1 from GCC 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:9bc6b23d11697545e8a951ccd60691b1e58b98c2
commit r14-8981-g9bc6b23d11697545e8a951ccd60691b1e58b98c2
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Feb 14 10:20:31 2024 -0500
c++: synthesized_method_walk context independence [PR113908]
In the second testcase below, during ahead of time checking of the
non-dependent new-expr we synthesize B's copy ctor, which we expect to
get defined as deleted since A's copy ctor is inaccessible. But during
access checking thereof, enforce_access incorrectly decides to defer it
since we're in a template context according to current_template_parms
(before r14-557 it checked processing_template_decl which got cleared
from implicitly_declare_fn), which leads to the access check leaking out
to the template context that triggered the synthesization, and B's copy
ctor getting declared as non-deleted.
This patch fixes this by using maybe_push_to_top_level to clear the
context (including current_template_parms) before proceeding with the
synthesization. We could do this from implicitly_declare_fn, but it's
better to do it more generally from synthesized_method_walk for sake of
its other callers.
This turns out to fix PR113332 as well: there the lambda context
triggering synthesization was causing maybe_dummy_object to misbehave,
but now synthesization is sufficiently context-independent.
PR c++/113908
PR c++/113332
gcc/cp/ChangeLog:
* method.cc (synthesized_method_walk): Use maybe_push_to_top_level.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-nsdmi11.C: New test.
* g++.dg/template/non-dependent31.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557
2024-02-13 13:57 [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor ppalka at gcc dot gnu.org
` (2 preceding siblings ...)
2024-02-14 15:21 ` cvs-commit at gcc dot gnu.org
@ 2024-02-14 15:22 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-14 15:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113908
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-14 15:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 13:57 [Bug c++/113908] New: [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor ppalka at gcc dot gnu.org
2024-02-13 13:59 ` [Bug c++/113908] [14 Regression] bogus access error with new-expr of current non-template class with implicitly deleted copy ctor since r14-557 ppalka at gcc dot gnu.org
2024-02-13 14:01 ` jakub at gcc dot gnu.org
2024-02-14 15:21 ` cvs-commit at gcc dot gnu.org
2024-02-14 15:22 ` 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).