Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format-test fails 3 tests under GCC with -std=c++11 rather than -std=gnu++11 #1787

Closed
tonyelewis opened this issue Jul 20, 2020 · 7 comments
Closed

Comments

@tonyelewis
Copy link
Contributor

Building and running format-test on Ubuntu 20.04 with:

rm -rf build
mkdir build
cmake -GNinja -Bbuild -H. -DCMAKE_CXX_EXTENSIONS=OFF
ninja -C build format-test
build/bin/format-test

…I get three failures:

[...]

[ RUN      ] FormatterTest.FormatBin
[       OK ] FormatterTest.FormatBin (0 ms)
[ RUN      ] FormatterTest.FormatDec
../test/format-test.cc:1124: Failure
Value of: format("{0}", static_cast<__int128_t>((9223372036854775807L)) + 1)
  Actual: "0"
Expected: "9223372036854775808"
../test/format-test.cc:1126: Failure
Value of: format("{0}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "4294967295"
Expected: "-9223372036854775809"
../test/format-test.cc:1128: Failure
Value of: format("{0}", static_cast<__int128_t>((18446744073709551615UL)) + 1)
  Actual: "0"
Expected: "18446744073709551616"
../test/format-test.cc:1130: Failure
Value of: format("{0}", int128_max)
  Actual: "4294967295"
Expected: "170141183460469231731687303715884105727"
../test/format-test.cc:1132: Failure
Value of: format("{0}", int128_min)
  Actual: "0"
Expected: "-170141183460469231731687303715884105728"
../test/format-test.cc:1134: Failure
Value of: format("{0}", uint128_max)
  Actual: "4294967295"
Expected: "340282366920938463463374607431768211455"
[  FAILED  ] FormatterTest.FormatDec (0 ms)
[ RUN      ] FormatterTest.FormatHex
../test/format-test.cc:1165: Failure
Value of: format("{0:x}", static_cast<__int128_t>((9223372036854775807L)) + 1)
  Actual: "0"
Expected: "8000000000000000"
../test/format-test.cc:1167: Failure
Value of: format("{0:x}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "ffffffff"
Expected: "-8000000000000001"
../test/format-test.cc:1169: Failure
Value of: format("{0:x}", static_cast<__int128_t>((18446744073709551615UL)) + 1)
  Actual: "0"
Expected: "10000000000000000"
../test/format-test.cc:1171: Failure
Value of: format("{0:x}", int128_max)
  Actual: "ffffffff"
Expected: "7fffffffffffffffffffffffffffffff"
../test/format-test.cc:1172: Failure
Value of: format("{0:x}", int128_min)
  Actual: "0"
Expected: "-80000000000000000000000000000000"
../test/format-test.cc:1173: Failure
Value of: format("{0:x}", uint128_max)
  Actual: "ffffffff"
Expected: "ffffffffffffffffffffffffffffffff"
[  FAILED  ] FormatterTest.FormatHex (0 ms)
[ RUN      ] FormatterTest.FormatOct
../test/format-test.cc:1200: Failure
Value of: format("{0:o}", static_cast<__int128_t>((9223372036854775807L)) + 1)
  Actual: "0"
Expected: "1000000000000000000000"
../test/format-test.cc:1202: Failure
Value of: format("{0:o}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "37777777777"
Expected: "-1000000000000000000001"
../test/format-test.cc:1204: Failure
Value of: format("{0:o}", static_cast<__int128_t>((18446744073709551615UL)) + 1)
  Actual: "0"
Expected: "2000000000000000000000"
../test/format-test.cc:1206: Failure
Value of: format("{0:o}", int128_max)
  Actual: "37777777777"
Expected: "1777777777777777777777777777777777777777777"
../test/format-test.cc:1208: Failure
Value of: format("{0:o}", int128_min)
  Actual: "0"
Expected: "-2000000000000000000000000000000000000000000"
../test/format-test.cc:1210: Failure
Value of: format("{0:o}", uint128_max)
  Actual: "37777777777"
Expected: "3777777777777777777777777777777777777777777"
[  FAILED  ] FormatterTest.FormatOct (0 ms)
[ RUN      ] FormatterTest.FormatIntLocale
[       OK ] FormatterTest.FormatIntLocale (0 ms)

[...]

[----------] Global test environment tear-down
[==========] 114 tests from 12 test cases ran. (14 ms total)
[  PASSED  ] 111 tests.
[  FAILED  ] 3 tests, listed below:
[  FAILED  ] FormatterTest.FormatDec
[  FAILED  ] FormatterTest.FormatHex
[  FAILED  ] FormatterTest.FormatOct

 3 FAILED TESTS

I think this is cause by the -DCMAKE_CXX_EXTENSIONS=OFF making the compilation command use -std=c++11 rather than -std=gnu++11.

@vitaut
Copy link
Contributor

vitaut commented Jul 20, 2020

Looks like the same issue as #1725 which is already fixed in master.

@tonyelewis
Copy link
Contributor Author

Ah 🤦‍♂️. Sorry - I didn't see #1725.

I don't think this is fully fixed in master, though there are now fewer failures. With the above instructions, I'm now seeing the following on master:

[...]

[ RUN      ] FormatterTest.FormatBin
[       OK ] FormatterTest.FormatBin (0 ms)
[ RUN      ] FormatterTest.FormatDec
../test/format-test.cc:1122: Failure
Value of: format("{0}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "340282366920938463454151235394913435647"
Expected: "-9223372036854775809"
../test/format-test.cc:1128: Failure
Value of: format("{0}", int128_min)
  Actual: "170141183460469231731687303715884105728"
Expected: "-170141183460469231731687303715884105728"
[  FAILED  ] FormatterTest.FormatDec (0 ms)
[ RUN      ] FormatterTest.FormatHex
../test/format-test.cc:1163: Failure
Value of: format("{0:x}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "ffffffffffffffff7fffffffffffffff"
Expected: "-8000000000000001"
../test/format-test.cc:1168: Failure
Value of: format("{0:x}", int128_min)
  Actual: "80000000000000000000000000000000"
Expected: "-80000000000000000000000000000000"
[  FAILED  ] FormatterTest.FormatHex (0 ms)
[ RUN      ] FormatterTest.FormatOct
../test/format-test.cc:1198: Failure
Value of: format("{0:o}", static_cast<__int128_t>((-9223372036854775807L-1)) - 1)
  Actual: "3777777777777777777776777777777777777777777"
Expected: "-1000000000000000000001"
../test/format-test.cc:1204: Failure
Value of: format("{0:o}", int128_min)
  Actual: "2000000000000000000000000000000000000000000"
Expected: "-2000000000000000000000000000000000000000000"
[  FAILED  ] FormatterTest.FormatOct (0 ms)
[ RUN      ] FormatterTest.FormatIntLocale
[       OK ] FormatterTest.FormatIntLocale (0 ms)

[...]

[----------] Global test environment tear-down
[==========] 114 tests from 12 test cases ran. (13 ms total)
[  PASSED  ] 111 tests.
[  FAILED  ] 3 tests, listed below:
[  FAILED  ] FormatterTest.FormatDec
[  FAILED  ] FormatterTest.FormatHex
[  FAILED  ] FormatterTest.FormatOct

@vitaut vitaut reopened this Jul 21, 2020
@vitaut vitaut removed the duplicate label Jul 21, 2020
@vitaut
Copy link
Contributor

vitaut commented Jul 30, 2020

Should be fixed as part of #1725.

@vitaut vitaut closed this as completed Jul 30, 2020
@tonyelewis
Copy link
Contributor Author

I'm sorry to report that I'm still seeing the above test failures (with the failed tests' source line numbers increased by 1) in the current master (21c8b5c1421ae04df00a97e4c396ffb7b26916bc).

@vitaut
Copy link
Contributor

vitaut commented Jul 30, 2020

Thanks for double-checking. There was one more issue with numeric_limits which is worked around in 51d0552.

@vitaut vitaut closed this as completed Jul 30, 2020
@tonyelewis
Copy link
Contributor Author

Yep - that seems to have done the trick. Thanks very much.

@tonyelewis
Copy link
Contributor Author

I'm also seeing allocation-size-too-big from the AddressSanitizer but I'm assuming that's not worth reporting because it's from the test code with the comment "Check if std::allocator throws on allocating max size_t / 2 chars".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants