public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96848] New: Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter
@ 2020-08-30 1:03 northon_patrick3 at yahoo dot ca
2021-08-17 7:06 ` [Bug c++/96848] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: northon_patrick3 at yahoo dot ca @ 2020-08-30 1:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96848
Bug ID: 96848
Summary: Inherited conditionally explicit constructors via
using declaration do not enforce explicitness if
dependent on template parameter
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: northon_patrick3 at yahoo dot ca
Target Milestone: ---
Example: https://godbolt.org/z/4x9r7e
```cpp
#include <iostream>
#include <type_traits>
struct E {};
struct F {};
struct G {};
template <typename From_, typename To_>
constexpr bool isValidImplicitConvert = false;
template <>
constexpr bool isValidImplicitConvert<E, G> = true;
template <typename T_>
struct A
{
template <typename OT_>
explicit(!isValidImplicitConvert<OT_, T_>) constexpr A(const OT_ &) {}
//explicit(isValidImplicitConvert<E, T_>) constexpr A(E) {}
//explicit(isValidImplicitConvert<F, T_>) constexpr A(F) {}
};
template <typename T_>
struct B : public A<T_>
{
using A<T_>::A;
};
int main(int, char **)
{
std::cout << std::is_convertible_v<E, A<G>> << '\n';
std::cout << std::is_convertible_v<F, A<G>> << '\n';
std::cout << std::is_convertible_v<E, B<G>> << '\n';
std::cout << std::is_convertible_v<F, B<G>> << '\n';
return 0;
}
```
Output:
```
1
0
1
1
```
Expected output:
```
1
0
1
0
```
When inheriting constructors from a base class via a using declaration, if said
constructors are conditionally explicit and the condition is dependent on a
deduced template parameter, the explicit state is ignored.
Clang give the expected output, however I am not sure who is correct.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96848] Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter
2020-08-30 1:03 [Bug c++/96848] New: Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter northon_patrick3 at yahoo dot ca
@ 2021-08-17 7:06 ` pinskia at gcc dot gnu.org
2021-08-17 7:09 ` pinskia at gcc dot gnu.org
2023-02-19 20:12 ` oliver.rosten at googlemail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96848
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
ICC, clang and MSVC all agree the output should be 1010.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96848] Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter
2020-08-30 1:03 [Bug c++/96848] New: Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter northon_patrick3 at yahoo dot ca
2021-08-17 7:06 ` [Bug c++/96848] " pinskia at gcc dot gnu.org
@ 2021-08-17 7:09 ` pinskia at gcc dot gnu.org
2023-02-19 20:12 ` oliver.rosten at googlemail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17 7:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96848
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-08-17
Ever confirmed|0 |1
Depends on| |85251
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. I suspect PR 85251 is the underlying issue though, GCC loses
explicit even in the unconditional case.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85251
[Bug 85251] Using declaration for base class constructor looses explicit.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96848] Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter
2020-08-30 1:03 [Bug c++/96848] New: Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter northon_patrick3 at yahoo dot ca
2021-08-17 7:06 ` [Bug c++/96848] " pinskia at gcc dot gnu.org
2021-08-17 7:09 ` pinskia at gcc dot gnu.org
@ 2023-02-19 20:12 ` oliver.rosten at googlemail dot com
2 siblings, 0 replies; 4+ messages in thread
From: oliver.rosten at googlemail dot com @ 2023-02-19 20:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96848
Oliver Rosten <oliver.rosten at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |oliver.rosten at googlemail dot co
| |m
--- Comment #3 from Oliver Rosten <oliver.rosten at googlemail dot com> ---
I just came across an issue which I think has the same underlying cause:
https://godbolt.org/z/Ph8xbeM7s
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-19 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 1:03 [Bug c++/96848] New: Inherited conditionally explicit constructors via using declaration do not enforce explicitness if dependent on template parameter northon_patrick3 at yahoo dot ca
2021-08-17 7:06 ` [Bug c++/96848] " pinskia at gcc dot gnu.org
2021-08-17 7:09 ` pinskia at gcc dot gnu.org
2023-02-19 20:12 ` oliver.rosten at googlemail 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).