_Literal_zero_is_expected() referenced in <compare> not defined anywhere? #4697
-
I am getting a link error with an unresolved external void std::_Literal_zero_is_expected() used in function std::_Literal_zero. I am no expert in the stl, so I ask this question here rather than assuming it is an issue - is/should _Literal_zero_is_expected be actually defined anywhere? I have cloned and searched the stl and not found it. Cheers. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It's intentionally never defined. If you're seeing this, you've got code somewhere that's attempting to compare a spaceship operator result against an int that isn't a literal
#include <compare>
#include <print>
#include <string>
using namespace std;
int main() {
const string cats{"cats"};
const string dogs{"dogs"};
println("(cats <=> dogs) < 0: {}", (cats <=> dogs) < 0);
#ifndef SKIP_BAD_CODE
println("(cats <=> dogs) < 5: {}", (cats <=> dogs) < 5);
#endif
}
|
Beta Was this translation helpful? Give feedback.
-
A compiler should never generate a call to It's possible that you encountered a compiler bug, but a reproducible example is needed for further analysis. |
Beta Was this translation helpful? Give feedback.
It's intentionally never defined. If you're seeing this, you've got code somewhere that's attempting to compare a spaceship operator result against an int that isn't a literal
0
.