This is an archive of the discontinued LLVM Phabricator instance.

Tolerate incorrect return type for 'isinf' and 'isnan' in tests.
ClosedPublic

Authored by EricWF on May 2 2016, 1:55 PM.

Details

Summary

GLIBC recently removed the incorrect int isinf(double) and int isnan(double) overloads in C++11 and greater. This causes previously XFAIL: linux tests to start passing.

Since there is no longer a way to 'XFAIL' the tests I choose to simply tolerate this bug.

See https://sourceware.org/bugzilla/show_bug.cgi?id=19439

Diff Detail

Event Timeline

EricWF updated this revision to Diff 55889.May 2 2016, 1:55 PM
EricWF retitled this revision from to Tolerate incorrect return type for 'isinf' and 'isnan' it tests..
EricWF updated this object.
EricWF added reviewers: rsmith, mclow.lists.
EricWF retitled this revision from Tolerate incorrect return type for 'isinf' and 'isnan' it tests. to Tolerate incorrect return type for 'isinf' and 'isnan' in tests..
EricWF added a subscriber: cfe-commits.

I think you could lean on the linker to cause the test to fail when the type is wrong:

bool isinf(double);

typedef int (*expected_signature)(double);

void assert_via_linker(decltype(isinf) blah);
void assert_via_linker(expected_signature blah) {}

void foo() {
  assert_via_linker(isinf);
}
EricWF added a comment.May 2 2016, 2:45 PM

I think you could lean on the linker to cause the test to fail when the type is wrong:

bool isinf(double);

typedef int (*expected_signature)(double);

void assert_via_linker(decltype(isinf) blah);
void assert_via_linker(expected_signature blah) {}

void foo() {
  assert_via_linker(isinf);
}

Alternatively static_assert(std::is_same<decltype(isinf((double)0)), bool>::value); :-P

Testing the return type isn't the problem. The problem is telling LIT *when* we expect the test to fail using the XFAIL directive.

The test will pass for:

  • non-linux systems
  • GLIBC >= 2.26 and C++ >= 11.

The test will fail for:

  • GLIBC < 2.26
  • GLIBC >= 2.26 and C++ < 11.

Trying to encode that within 'XFAIL' is currently not possible and

Alternatively static_assert(std::is_same<decltype(isinf((double)0)), bool>::value); :-P

Testing the return type isn't the problem. The problem is telling LIT *when* we expect the test to fail using the XFAIL directive.

Ohhhh. I see.

mclow.lists edited edge metadata.May 2 2016, 10:41 PM

How about not using XFAIL?
Instead, just test for those two conditions.

Psuedo-code:

#if defined(GLIBC)
#if GLIBC < 226
#error
#elif TEST_STD_VER >= 11
#error
#endif.

How about not using XFAIL?
Instead, just test for those two conditions.

Psuedo-code:

#if defined(GLIBC)
#if GLIBC < 226
#error
#elif TEST_STD_VER >= 11
#error
#endif.

Because I want this test to pass, not fail. I definitely don't want to force failure of a passing test.
(Also it's not really that easy to test the GLIBC version.)

EricWF accepted this revision.May 27 2016, 3:20 PM
EricWF added a reviewer: EricWF.

Accepting to get the test suite passing on newer linux distributions again. I tried modifying the tests to test the GLIBC version but IMO it was more complexity than it was worth.

This revision is now accepted and ready to land.May 27 2016, 3:20 PM
EricWF closed this revision.May 27 2016, 3:26 PM
test/std/numerics/c.math/cmath.pass.cpp