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

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).