public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11
@ 2022-02-16 14:45 armenchik at mail dot ru
2022-02-16 22:53 ` [Bug c++/104567] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: armenchik at mail dot ru @ 2022-02-16 14:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104567
Bug ID: 104567
Summary: SFINAE check failure starting gcc 4.7.1 and up with
-std=c++11
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: armenchik at mail dot ru
Target Milestone: ---
template <typename _TAny, char const* value = _TAny::param>
constexpr bool has_char_static_param(int)
{ return true; }
template <typename _TAny>
constexpr bool has_char_static_param(...)
{ return false; }
struct checked_type
{
constexpr static char param[] = "param"; // <- everything works fine
//constexpr static int param = 0; // <- sfinae works fine, fails static
assert
//int param; // <- sfinae fails! reporting error during param substitution
//char const* param; // <- sfinae fails again as above
};
int main()
{
static_assert(has_char_static_param<checked_type>(0), "check failed");
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104567] SFINAE check failure starting gcc 4.7.1 and up with -std=c++11
2022-02-16 14:45 [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11 armenchik at mail dot ru
@ 2022-02-16 22:53 ` pinskia at gcc dot gnu.org
2022-02-16 22:58 ` [Bug c++/104567] SFINAE check failure with trying to access member field pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-16 22:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104567
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL|https://godbolt.org/z/eGc9s |
|n6GM |
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://godbolt.org/z/eGc9sn6GM
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104567] SFINAE check failure with trying to access member field
2022-02-16 14:45 [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11 armenchik at mail dot ru
2022-02-16 22:53 ` [Bug c++/104567] " pinskia at gcc dot gnu.org
@ 2022-02-16 22:58 ` pinskia at gcc dot gnu.org
2022-02-16 23:03 ` pinskia at gcc dot gnu.org
2022-02-17 10:38 ` [Bug c++/104567] SFINAE check failure with trying to access member field on the default template argument for a function redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-16 22:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104567
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Known to fail| |4.1.2, 4.6.4
Last reconfirmed| |2022-02-16
Summary|SFINAE check failure |SFINAE check failure with
|starting gcc 4.7.1 and up |trying to access member
|with -std=c++11 |field
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it has always failed.
Here is a C++98 testcase which shows the issue even with GCC 4.1.2:
template <typename _TAny, char const* value = _TAny::param>
bool has_char_static_param(int)
{ return true; }
template <typename _TAny>
bool has_char_static_param(...)
{ return false; }
struct checked_type
{
int param;
};
int main()
{
int t = has_char_static_param<checked_type>(0);
return t;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104567] SFINAE check failure with trying to access member field
2022-02-16 14:45 [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11 armenchik at mail dot ru
2022-02-16 22:53 ` [Bug c++/104567] " pinskia at gcc dot gnu.org
2022-02-16 22:58 ` [Bug c++/104567] SFINAE check failure with trying to access member field pinskia at gcc dot gnu.org
@ 2022-02-16 23:03 ` pinskia at gcc dot gnu.org
2022-02-17 10:38 ` [Bug c++/104567] SFINAE check failure with trying to access member field on the default template argument for a function redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-16 23:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104567
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.1.2 |4.4.7
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh I forgot default template arguments for function calls only came to be part
of C++11.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104567] SFINAE check failure with trying to access member field on the default template argument for a function
2022-02-16 14:45 [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11 armenchik at mail dot ru
` (2 preceding siblings ...)
2022-02-16 23:03 ` pinskia at gcc dot gnu.org
@ 2022-02-17 10:38 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-17 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104567
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |12.0
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A testcase that shows the bug is a lot more useful than one that needs
something uncommented to show the bug.
template <typename _TAny, char const* value = _TAny::param>
constexpr bool has_char_static_param(int)
{ return true; }
template <typename _TAny>
constexpr bool has_char_static_param(...)
{ return false; }
struct works1
{
constexpr static char param[] = "param";
};
struct works2
{
constexpr static int param = 0;
};
struct fails
{
char const* param; // not static
};
static_assert(has_char_static_param<works1>(0), "");
static_assert(!has_char_static_param<works2>(0), "");
static_assert(!has_char_static_param<fails>(0), ""); // FAILS
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-17 10:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 14:45 [Bug c++/104567] New: SFINAE check failure starting gcc 4.7.1 and up with -std=c++11 armenchik at mail dot ru
2022-02-16 22:53 ` [Bug c++/104567] " pinskia at gcc dot gnu.org
2022-02-16 22:58 ` [Bug c++/104567] SFINAE check failure with trying to access member field pinskia at gcc dot gnu.org
2022-02-16 23:03 ` pinskia at gcc dot gnu.org
2022-02-17 10:38 ` [Bug c++/104567] SFINAE check failure with trying to access member field on the default template argument for a function redi 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).