public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type
@ 2024-08-19 13:32 amy at amyspark dot me
2024-08-19 14:38 ` [Bug c++/116417] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: amy at amyspark dot me @ 2024-08-19 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116417
Bug ID: 116417
Summary: SFINAE on std::is_destructible cannot handle
destructor of scalar type
Product: gcc
Version: 14.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amy at amyspark dot me
Target Milestone: ---
Hi all,
I have the following test case that compiles in Clang 20.0.0 commit
7d5281a66d5d42c65cfb9d95eaf9aa01afb089fb :
```c++
#include <type_traits>
namespace _impl {
template<typename _Ty, typename =
decltype(std::declval<_Ty&>().~_Ty())>
constexpr auto _try_is_destructible(int) -> std::true_type;
template<typename>
constexpr auto _try_is_destructible(...) -> std::false_type;
}
template<typename _Ty>
struct is_destructible : std::conditional_t<
!std::is_void_v<_Ty> && !std::is_unbounded_array_v<_Ty> &&
!std::is_function_v<_Ty>,
std::conditional_t<
std::is_reference_v<_Ty>,
std::true_type,
decltype(
_impl::_try_is_destructible<std::remove_all_extents_t<_Ty>>(0)
)
>,
std::false_type
> {};
template<typename _Ty>
inline constexpr bool is_destructible_v = is_destructible<_Ty>::value;
static_assert(is_destructible_v<int&>);
int main(int, char**) {
return 0;
}
```
GCC 14.1 refuses to build with the following error:
```
<source>: In substitution of 'template<class _Ty, class> constexpr
std::true_type _impl::_try_is_destructible(int) [with _Ty = int&;
<template-parameter-1-2> = <missing>]':
<source>:17:63: required from 'struct is_destructible<int&>'
17 |
_impl::_try_is_destructible<std::remove_all_extents_t<_Ty>>(0)
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
<source>:24:65: required from 'constexpr const bool is_destructible_v<int&>'
24 | inline constexpr bool is_destructible_v = is_destructible<_Ty>::value;
| ^~~~~
<source>:26:15: required from here
26 | static_assert(is_destructible_v<int&>);
| ^~~~~~~~~~~~~~~~~~~~~~~
<source>:4:74: error: 'std::declval<int&>()' is not of type 'int&'
4 | template<typename _Ty, typename =
decltype(std::declval<_Ty&>().~_Ty())>
|
~~~~~~~~~~~~~~~~~~~~~~^~~
ASM generation compiler returned: 1
<source>: In substitution of 'template<class _Ty, class> constexpr
std::true_type _impl::_try_is_destructible(int) [with _Ty = int&;
<template-parameter-1-2> = <missing>]':
<source>:17:63: required from 'struct is_destructible<int&>'
17 |
_impl::_try_is_destructible<std::remove_all_extents_t<_Ty>>(0)
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
<source>:24:65: required from 'constexpr const bool is_destructible_v<int&>'
24 | inline constexpr bool is_destructible_v = is_destructible<_Ty>::value;
| ^~~~~
<source>:26:15: required from here
26 | static_assert(is_destructible_v<int&>);
| ^~~~~~~~~~~~~~~~~~~~~~~
<source>:4:74: error: 'std::declval<int&>()' is not of type 'int&'
4 | template<typename _Ty, typename =
decltype(std::declval<_Ty&>().~_Ty())>
|
~~~~~~~~~~~~~~~~~~~~~~^~~
Execution build compiler returned: 1
```
Looks like it's been found and worked around before, but no report has been
filed: https://stackoverflow.com/a/53458189
Godbolt here: https://godbolt.org/z/Edes1sjzo
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116417] SFINAE on std::is_destructible cannot handle destructor of scalar type
2024-08-19 13:32 [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type amy at amyspark dot me
@ 2024-08-19 14:38 ` pinskia at gcc dot gnu.org
2024-08-19 14:52 ` [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-19 14:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116417
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
template<typename _Tp>
_Tp declval();
template <class _Ty>
using t = decltype(declval<_Ty&>().~_Ty());
template <class _Ty, class T1 = t<_Ty>>
void f(int);
template <class _Ty>
int f(long);
int tt = f<int&>(0);
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor
2024-08-19 13:32 [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type amy at amyspark dot me
2024-08-19 14:38 ` [Bug c++/116417] " pinskia at gcc dot gnu.org
@ 2024-08-19 14:52 ` pinskia at gcc dot gnu.org
2024-08-19 14:54 ` redi at gcc dot gnu.org
2024-08-20 14:56 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-19 14:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116417
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note for my reduced testcase, EDG rejects it because it is able to compile
`t<int&>`:
```
"<source>", line 12: error: a value of type "void" cannot be used to initialize
an entity of type "int"
int tt = f<int&>(0);
^
```
MSVC and clang accepts it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor
2024-08-19 13:32 [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type amy at amyspark dot me
2024-08-19 14:38 ` [Bug c++/116417] " pinskia at gcc dot gnu.org
2024-08-19 14:52 ` [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor pinskia at gcc dot gnu.org
@ 2024-08-19 14:54 ` redi at gcc dot gnu.org
2024-08-20 14:56 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 14:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116417
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-08-19
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor
2024-08-19 13:32 [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type amy at amyspark dot me
` (2 preceding siblings ...)
2024-08-19 14:54 ` redi at gcc dot gnu.org
@ 2024-08-20 14:56 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-20 14:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116417
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |easyhack
CC| |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
For anyone interested in working on this this, it looks like we just need to
give finish_pseudo_destructor_expr a 'complain' parameter and guard its
diagnostics with it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-20 14:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-19 13:32 [Bug c++/116417] New: SFINAE on std::is_destructible cannot handle destructor of scalar type amy at amyspark dot me
2024-08-19 14:38 ` [Bug c++/116417] " pinskia at gcc dot gnu.org
2024-08-19 14:52 ` [Bug c++/116417] SFINAE on std::is_destructible cannot handle pseudo destructor pinskia at gcc dot gnu.org
2024-08-19 14:54 ` redi at gcc dot gnu.org
2024-08-20 14:56 ` 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).