public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97198] New: __is_constructible(int[], int) should return true
@ 2020-09-25 5:29 kariya_mitsuru at hotmail dot com
2020-09-25 8:48 ` [Bug c++/97198] " redi at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2020-09-25 5:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
Bug ID: 97198
Summary: __is_constructible(int[], int) should return true
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kariya_mitsuru at hotmail dot com
Target Milestone: ---
The sample code below returns 0 if it is compiled by GCC HEAD with c++2a mode
but I think that it should return 1.
============ sample code ============
int main()
{
return __is_constructible(int[], int);
}
============ sample code ============
cf. https://wandbox.org/permlink/nFQtqfxDNJPZRhZt
The C++20 DIS 20.15.4.3 Type properties[meta.unary.prop] p.8 says,
The predicate condition for a template specialization is_constructible<T,
Args...> shall be satisfied if and only if the following variable definition
would be well-formed for some invented variable t:
T t(declval<Args>()...);
...
cf. https://timsong-cpp.github.io/cppwp/n4861/meta#unary.prop-8
If T = int[] and Args = int, it is well-formed.
============ sample code ============
int main()
{
using T = int[];
T t(42);
}
============ sample code ============
cf. https://wandbox.org/permlink/2MhF1PNUbgq7mNAC
So, I think that __is_constructible(int[], int) should return true even though
int[] is imcomplete type. (unless it is a defect of the C++20 DIS)
Related PR:
PR94149 __is_constructible doesn't know about C++20 parenthesized init for
arrays
PR90532 [8/9/10 Regression] is_constructible_v<int[]> and
is_default_constructible_v<int[]> should agree
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
@ 2020-09-25 8:48 ` redi at gcc dot gnu.org
2020-09-25 12:53 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-25 8:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-09-25
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
2020-09-25 8:48 ` [Bug c++/97198] " redi at gcc dot gnu.org
@ 2020-09-25 12:53 ` mpolacek at gcc dot gnu.org
2020-09-25 17:26 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 12:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
2020-09-25 8:48 ` [Bug c++/97198] " redi at gcc dot gnu.org
2020-09-25 12:53 ` mpolacek at gcc dot gnu.org
@ 2020-09-25 17:26 ` mpolacek at gcc dot gnu.org
2020-09-25 18:49 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu.org
Status|ASSIGNED |SUSPENDED
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm actually not sure what we want to do. I'd expect:
__is_constructible(int[]) // false in any mode
__is_constructible(int[], int) // true in C++20, false in C++17
__is_constructible(int[], int, int) // true in C++20, false in C++17
but that would go against PR90532.
Suspending until it's clear what we want.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (2 preceding siblings ...)
2020-09-25 17:26 ` mpolacek at gcc dot gnu.org
@ 2020-09-25 18:49 ` redi at gcc dot gnu.org
2020-09-25 19:06 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-25 18:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Hmm. It should be false for construction from no arguments i.e.
__is_constructible(int[]).
But thanks to parenthesized aggregate init, you can actually do:
using T = int[];
T t(1);
It's still true that int[] is incomplete, but in the example above you actually
construct is a int[1] not int[]. I think this should be an LWG issue.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (3 preceding siblings ...)
2020-09-25 18:49 ` redi at gcc dot gnu.org
@ 2020-09-25 19:06 ` mpolacek at gcc dot gnu.org
2020-10-05 11:02 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 19:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> Hmm. It should be false for construction from no arguments i.e.
> __is_constructible(int[]).
>
> But thanks to parenthesized aggregate init, you can actually do:
>
> using T = int[];
> T t(1);
>
> It's still true that int[] is incomplete, but in the example above you
> actually construct is a int[1] not int[].
Agreed.
> I think this should be an LWG issue.
Yes, I'd prefer LWG guidance before making any changes here.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (4 preceding siblings ...)
2020-09-25 19:06 ` mpolacek at gcc dot gnu.org
@ 2020-10-05 11:02 ` redi at gcc dot gnu.org
2022-03-12 7:48 ` lichray at gmail dot com
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-10-05 11:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is now https://wg21.link/lwg3486
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (5 preceding siblings ...)
2020-10-05 11:02 ` redi at gcc dot gnu.org
@ 2022-03-12 7:48 ` lichray at gmail dot com
2022-03-12 10:10 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: lichray at gmail dot com @ 2022-03-12 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
Zhihao Yuan <lichray at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lichray at gmail dot com
--- Comment #5 from Zhihao Yuan <lichray at gmail dot com> ---
Encountered this today. In case I cannot show up when discussing LWG3486, my
use case is that C(in_place_type<T[]>, a, b, c) should "just works." It's up to
C how to deal with it. In my case, it's new T[].
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (6 preceding siblings ...)
2022-03-12 7:48 ` lichray at gmail dot com
@ 2022-03-12 10:10 ` redi at gcc dot gnu.org
2022-03-14 11:51 ` redi at gcc dot gnu.org
2022-03-14 17:02 ` lichray at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-12 10:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'll add a note to the lwg issue, as I'll never remember there was a comment
about it here.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (7 preceding siblings ...)
2022-03-12 10:10 ` redi at gcc dot gnu.org
@ 2022-03-14 11:51 ` redi at gcc dot gnu.org
2022-03-14 17:02 ` lichray at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-14 11:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Zhihao Yuan from comment #5)
> Encountered this today. In case I cannot show up when discussing LWG3486, my
> use case is that C(in_place_type<T[]>, a, b, c) should "just works." It's up
> to C how to deal with it. In my case, it's new T[].
I was going to add a note to the issue, but I don't know what to add. What is
C? Why wouldn't it work today? Why does std::is_constructible affect it?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97198] __is_constructible(int[], int) should return true
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
` (8 preceding siblings ...)
2022-03-14 11:51 ` redi at gcc dot gnu.org
@ 2022-03-14 17:02 ` lichray at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: lichray at gmail dot com @ 2022-03-14 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97198
--- Comment #8 from Zhihao Yuan <lichray at gmail dot com> ---
(In reply to Jonathan Wakely from comment #7)
> (In reply to Zhihao Yuan from comment #5)
> > Encountered this today. In case I cannot show up when discussing LWG3486, my
> > use case is that C(in_place_type<T[]>, a, b, c) should "just works." It's up
> > to C how to deal with it. In my case, it's new T[].
>
> I was going to add a note to the issue, but I don't know what to add. What
> is C? Why wouldn't it work today? Why does std::is_constructible affect it?
I meant to let C stand for some type C's constructor here. I wanted to express
the following: in_place_type is often used by type-erasures to forward all
information that is expression-equivalent to some form of initialization. Let's
say I want to create an object of type C with
C obj(in_place_type<U>, a, b, c);
where obj erases the type of a hypothetical object created in
U x(a, b, c);
Because type erasure means to erase the U in in_place_type<U>, it doesn't
matter if U != decltype(x). It works according to the literal interpretation of
the standard today. But if we say std::is_constructible_v<int[], int, int, int>
== false, extra efforts are needed to restore the meaning of in_place_type.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-03-14 17:02 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 5:29 [Bug c++/97198] New: __is_constructible(int[], int) should return true kariya_mitsuru at hotmail dot com
2020-09-25 8:48 ` [Bug c++/97198] " redi at gcc dot gnu.org
2020-09-25 12:53 ` mpolacek at gcc dot gnu.org
2020-09-25 17:26 ` mpolacek at gcc dot gnu.org
2020-09-25 18:49 ` redi at gcc dot gnu.org
2020-09-25 19:06 ` mpolacek at gcc dot gnu.org
2020-10-05 11:02 ` redi at gcc dot gnu.org
2022-03-12 7:48 ` lichray at gmail dot com
2022-03-12 10:10 ` redi at gcc dot gnu.org
2022-03-14 11:51 ` redi at gcc dot gnu.org
2022-03-14 17:02 ` lichray at gmail dot com
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).