static_assert failure on OpenBSD/i386 On TestVariant.cpp: "Expected small index type"
Categories
(Core :: MFBT, defect)
Tracking
()
People
(Reporter: gaston, Assigned: mozbugz)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: regression)
Attachments
(1 file)
Probably since bug #1621865, the native build fails on 32-bits platforms, as can be seen on http://buildbot.rhaalovely.net/nine/#/builders/1/builds/1091/steps/8/logs/stdio
mfbt/tests/TestVariant.cpp:809:5: error: static_assert failed due to requirement 'sizeof (aIndex) < sizeof(unsigned long)' "Expected small index type"
162:07.17 static_assert(sizeof(aIndex) < sizeof(size_t), "Expected small index type");
Assignee | ||
Comment 1•3 years ago
•
|
||
Thank you for the report.
I believe the type of aIndex
should be uint_fast8_t
(it's chosen here), but this test doesn't account for the possibility that uint_fast8_t
could be as big as size_t
on some systems! 😅
Landry, could you please try to change the failing static_assert
in the test to:
static_assert(is_same_v<decltype(aIndex), uint_fast8_t>);
That's a better test anyway.
If it works, I'll prepare a patch.
Reporter | ||
Comment 2•3 years ago
|
||
i dunno where is_same_v
is supposed to come from but it seems that doesnt exist in clang 11 on OpenBSD.
171:56.32 /home/landry/src/m-c/mfbt/tests/TestVariant.cpp:809:19: error: use of undeclared identifier 'is_same_v'
171:56.32 static_assert(is_same_v<decltype(aIndex), uint_fast8_t>);
Reporter | ||
Comment 3•3 years ago
|
||
retrying with std::is_same_v
.. doh.
Reporter | ||
Comment 4•3 years ago
|
||
mfbt/tests/TestVariant
build succeeds on OpenBSD/i386 with
- static_assert(sizeof(aIndex) < sizeof(size_t), "Expected small index type");
+ static_assert(std::is_same_v<decltype(aIndex), uint_fast8_t>);
Assignee | ||
Comment 5•3 years ago
|
||
(In reply to Landry Breuil (:gaston) from comment #3)
retrying with
std::is_same_v
.. doh.
Haha, sorry about that, I did the same mistake when trying locally, but then forgot to update my comment here. 😅
(In reply to Landry Breuil (:gaston) from comment #4)
mfbt/tests/TestVariant
build succeeds on OpenBSD/i386
Great, thank you for confirming. I'll prepare a proper patch soon.
Updated•3 years ago
|
Assignee | ||
Comment 6•3 years ago
|
||
On some systems, uint_fast8_t may be as big as size_t! So the static_assert(sizeof(aIndex) < sizeof(size_t))
could fail there. The better test here is to check for the expected type (uint_fast8_t).
Now, since uint_fast8_t can be bigger than 8 bits, we may as well choose it for variant sizes greater than 255, up to UINT_FAST8_MAX.
(The added parentheses help clang-format distinguish '<' for tests vs for templates.)
Pushed by gsquelart@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9ca3637f9464 Better Tag type choice, fixed corresponding test - r=emilio
Comment 8•3 years ago
|
||
bugherder |
Updated•3 years ago
|
Description
•