https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110911

            Bug ID: 110911
           Summary: Confusing diagnostic on misplaced static_assert
           Product: gcc
           Version: og13 (devel/omp/gcc-13)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pacoarjonilla at yahoo dot es
  Target Milestone: ---

This code (note static_assert instead of static_cast)


#include <complex>
void f(float m)
{
    std::complex<double> c = std::complex<double>(static_assert<double>(m),0);
}


generates the diagnostic

<source>: In function 'void f(float)':
<source>:4:50: error: expected primary-expression before '(' token
    4 |     std::complex<double> c =
std::complex<double>(static_assert<double>(m),0);
      |                                                  ^
<source>:4:51: error: expected primary-expression before 'static_assert'
    4 |     std::complex<double> c =
std::complex<double>(static_assert<double>(m),0);
      |                      


But the problem is not before the '(' token, nor before static_assert.
A suggestion such as "static_assert not valid here. Did you mean
'static_cast'?" would be nice.

Reply via email to