Buggy test 20_util/exchange/1.cc

Diego Novillo dnovillo@google.com
Tue Oct 15 16:58:00 GMT 2013


This test fails to link unless compiled with -O2. The compiler is
eliding the whole body of test03(), so everything links and runs
properly.

// Deduce type of overloaded function
void
test03()
{
  bool test __attribute__((unused)) = true;
  int (*fp)(int);  int f(int);
  double f(double);
  std::exchange(fp, &f);
  VERIFY( fp != nullptr );
}

However, at -O0, the address of f() is really needed, so we fail to link.

This test really needs an empty f() function.  Would such a patch be OK?


Thanks.  Diego.



More information about the Libstdc++ mailing list