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.