public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103553] New: Show what decltype deduced in static_assert
@ 2021-12-04 14:41 mpolacek at gcc dot gnu.org
2021-12-04 14:41 ` [Bug c++/103553] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-04 14:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103553
Bug ID: 103553
Summary: Show what decltype deduced in static_assert
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
struct false_type { static constexpr bool value = false; };
struct true_type { static constexpr bool value = true; };
template<class T, class U>
struct is_same : false_type {};
template<class T>
struct is_same<T, T> : true_type {};
void
g ()
{
int &&r = 42;
static_assert (is_same<decltype(r), int>::value, "");
}
yields
$ ./cc1plus -quiet w.C
w.C: In function ‘void g()’:
w.C:12:45: error: static assertion failed
12 | static_assert (is_same<decltype(r), int>::value, "");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
It would be nice to see why though, show what type the decltype produced.
$ xclang++ -c w.C
w.C:12:3: error: static_assert failed due to requirement 'is_same<int &&,
int>::value' ""
static_assert (is_same<decltype(r), int>::value, "");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
which is much better.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/103553] Show what decltype deduced in static_assert
2021-12-04 14:41 [Bug c++/103553] New: Show what decltype deduced in static_assert mpolacek at gcc dot gnu.org
@ 2021-12-04 14:41 ` mpolacek at gcc dot gnu.org
2021-12-07 10:53 ` pinskia at gcc dot gnu.org
2021-12-07 15:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-04 14:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103553
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/103553] Show what decltype deduced in static_assert
2021-12-04 14:41 [Bug c++/103553] New: Show what decltype deduced in static_assert mpolacek at gcc dot gnu.org
2021-12-04 14:41 ` [Bug c++/103553] " mpolacek at gcc dot gnu.org
@ 2021-12-07 10:53 ` pinskia at gcc dot gnu.org
2021-12-07 15:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-07 10:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103553
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-12-07
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, we do it for the template case but if it was not in a template we
don't, notice:
#include <type_traits>
template<class T>
class f
{
int && r;
static_assert (std::is_same_v<decltype(r), int>,"");
};
class f1
{
int && r;
static_assert (std::is_same_v<decltype(r), int>,"");
};
void
g ()
{
int &&r = 42;
f<decltype(r)> t;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/103553] Show what decltype deduced in static_assert
2021-12-04 14:41 [Bug c++/103553] New: Show what decltype deduced in static_assert mpolacek at gcc dot gnu.org
2021-12-04 14:41 ` [Bug c++/103553] " mpolacek at gcc dot gnu.org
2021-12-07 10:53 ` pinskia at gcc dot gnu.org
@ 2021-12-07 15:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-07 15:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103553
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yes, I added that in GCC 11.
To make this work, I think we'll have to print parser->scope when there's one.
In this case it's
full-name "struct is_same<int&&, int>"
so that could be extracted and used in finish_static_assert.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-07 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 14:41 [Bug c++/103553] New: Show what decltype deduced in static_assert mpolacek at gcc dot gnu.org
2021-12-04 14:41 ` [Bug c++/103553] " mpolacek at gcc dot gnu.org
2021-12-07 10:53 ` pinskia at gcc dot gnu.org
2021-12-07 15:15 ` 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).