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

--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
A slight variation of the test causes GCC to hang (apparently in evaluating the
infinite loop). 


$ timeout -s 9 10 g++-trunk -c small.cpp
Killed
$ 
$ clang++-trunk -std=c++14 -c small.cpp
small.cpp:2:1: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
foo (int p)
^
small.cpp:6:5: note: constexpr evaluation hit maximum step limit; possible
infinite loop?
    t = 0; 
    ^
small.cpp:10:16: error: static_assert expression is not an integral constant
expression
static_assert (foo (1) == 0, "");
               ^~~~~~~~~~~~
small.cpp:6:5: note: constexpr evaluation hit maximum step limit; possible
infinite loop?
    t = 0; 
    ^
small.cpp:10:16: note: in call to 'foo(1)'
static_assert (foo (1) == 0, "");
               ^
2 errors generated.
$ 


------------------------------------


constexpr int
foo (int p)
{
  int t = 0; 
  while (1) 
    t = 0;     // was ';' 
  return t;
}

static_assert (foo (1) == 0, "");

Reply via email to