public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect
@ 2024-03-19 14:53 yronglin777 at gmail dot com
2024-03-19 16:17 ` [Bug c++/114395] [c++20+] " pinskia at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: yronglin777 at gmail dot com @ 2024-03-19 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
Bug ID: 114395
Summary: std::is_constructible_v result of const reference
incorrect
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yronglin777 at gmail dot com
Target Milestone: ---
https://godbolt.org/z/h5af6f5x9
```
#include <type_traits>
struct A {
int a;
};
struct B : public A {};
static_assert(!std::is_constructible_v<const B &, const A &>);
static_assert(!std::is_constructible_v<const B *, const A *>);
```
Clang and MSVC accepted this code, but gcc rejected.
```
<source>:8:15: error: static assertion failed
8 | static_assert(!std::is_constructible_v<const B &, const A &>);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler returned: 1
```
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
@ 2024-03-19 16:17 ` pinskia at gcc dot gnu.org
2024-03-19 16:28 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|std::is_constructible_v |[c++20+]
|result of const reference |std::is_constructible_v
|incorrect |result of const reference
| |incorrect
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, this fails only for C++20+.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
2024-03-19 16:17 ` [Bug c++/114395] [c++20+] " pinskia at gcc dot gnu.org
@ 2024-03-19 16:28 ` pinskia at gcc dot gnu.org
2024-03-19 16:40 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Except this works with C++20+ for GCC:
```
struct A {
int a;
};
struct B : public A {};
void f(const A &a)
{
typedef const B & Btype;
Btype b(a);
}
```
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
2024-03-19 16:17 ` [Bug c++/114395] [c++20+] " pinskia at gcc dot gnu.org
2024-03-19 16:28 ` pinskia at gcc dot gnu.org
@ 2024-03-19 16:40 ` mpolacek at gcc dot gnu.org
2024-03-19 16:49 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-03-19 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Changed with r10-5137-g43aae289866f5e:
commit 43aae289866f5ea55d187444520412554aa2e171
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Dec 3 15:59:40 2019 +0000
PR c++/91363 - P0960R3: Parenthesized initialization of aggregates.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (2 preceding siblings ...)
2024-03-19 16:40 ` mpolacek at gcc dot gnu.org
@ 2024-03-19 16:49 ` pinskia at gcc dot gnu.org
2024-03-19 17:10 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 16:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #3)
> Changed with r10-5137-g43aae289866f5e:
>
> commit 43aae289866f5ea55d187444520412554aa2e171
> Author: Marek Polacek <polacek@redhat.com>
> Date: Tue Dec 3 15:59:40 2019 +0000
>
> PR c++/91363 - P0960R3: Parenthesized initialization of aggregates.
Hmm, reading the paper, I am not 100% sure if GCC implemented this correctly
due to the wording of the design principles:
```
Any existing meaning of A(b) should not change.
```
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (3 preceding siblings ...)
2024-03-19 16:49 ` pinskia at gcc dot gnu.org
@ 2024-03-19 17:10 ` redi at gcc dot gnu.org
2024-03-19 17:14 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-19 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I disagree, A(b) definitely changed meaning. It now initializes A by copying
the base part of b
This is a combination of aggregates being allowed to have base classes and
paren-init doing aggregate-init.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (4 preceding siblings ...)
2024-03-19 17:10 ` redi at gcc dot gnu.org
@ 2024-03-19 17:14 ` mpolacek at gcc dot gnu.org
2024-03-19 17:19 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-03-19 17:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Right, another design principle is that () should work where {} works, and
const B &b{a}; works. A(b) previously didn't work so it's not really changing
meaning. So not a bug IMHO.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (5 preceding siblings ...)
2024-03-19 17:14 ` mpolacek at gcc dot gnu.org
@ 2024-03-19 17:19 ` redi at gcc dot gnu.org
2024-03-19 18:29 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-19 17:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
All of Clang, MSVC and EDG disagree with GCC though, so maybe there's a DR that
we're missing.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (6 preceding siblings ...)
2024-03-19 17:19 ` redi at gcc dot gnu.org
@ 2024-03-19 18:29 ` pinskia at gcc dot gnu.org
2024-03-19 19:07 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 18:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #7)
> All of Clang, MSVC and EDG disagree with GCC though, so maybe there's a DR
> that we're missing.
Maybe https://cplusplus.github.io/CWG/issues/1467.html (again).
See clang bug https://github.com/llvm/llvm-project/pull/77768 .
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (7 preceding siblings ...)
2024-03-19 18:29 ` pinskia at gcc dot gnu.org
@ 2024-03-19 19:07 ` pinskia at gcc dot gnu.org
2024-03-20 10:23 ` de34 at live dot cn
2024-03-20 12:47 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 19:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://eel.is/c++draft/dcl.init.general#16.2 applies here I think. Which comes
before the `Parenthesized aggregates initialization` clause. But I could be
wrong.
https://github.com/cplusplus/papers/issues/1494 is kinda of related.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (8 preceding siblings ...)
2024-03-19 19:07 ` pinskia at gcc dot gnu.org
@ 2024-03-20 10:23 ` de34 at live dot cn
2024-03-20 12:47 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: de34 at live dot cn @ 2024-03-20 10:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
Jiang An <de34 at live dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |de34 at live dot cn
--- Comment #10 from Jiang An <de34 at live dot cn> ---
I think this is basically CWG2709
(https://cplusplus.github.io/CWG/issues/2709.html).
Given CWG2709 is closed as NAD, we should reject such initializations.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/114395] [c++20+] std::is_constructible_v result of const reference incorrect
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
` (9 preceding siblings ...)
2024-03-20 10:23 ` de34 at live dot cn
@ 2024-03-20 12:47 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-03-20 12:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114395
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2024-03-20
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-03-20 12:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 14:53 [Bug c++/114395] New: std::is_constructible_v result of const reference incorrect yronglin777 at gmail dot com
2024-03-19 16:17 ` [Bug c++/114395] [c++20+] " pinskia at gcc dot gnu.org
2024-03-19 16:28 ` pinskia at gcc dot gnu.org
2024-03-19 16:40 ` mpolacek at gcc dot gnu.org
2024-03-19 16:49 ` pinskia at gcc dot gnu.org
2024-03-19 17:10 ` redi at gcc dot gnu.org
2024-03-19 17:14 ` mpolacek at gcc dot gnu.org
2024-03-19 17:19 ` redi at gcc dot gnu.org
2024-03-19 18:29 ` pinskia at gcc dot gnu.org
2024-03-19 19:07 ` pinskia at gcc dot gnu.org
2024-03-20 10:23 ` de34 at live dot cn
2024-03-20 12:47 ` mpolacek 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).