https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68288
Yuriy Solodkyy changed:
What|Removed |Added
CC||solodon at mail dot com
--- Comment #3 from Yuriy Solodkyy ---
This seems to be a genuine bug in GCC, not specific to floating-point UDL. It
is still present in GCC 10.2. ICC barks on it as well, but Clang and MSVC
accepts.
Consider:
struct s_points { unsigned long long value; };
inline s_points operator"" _sp(unsigned long long v) { return {v}; }
s_points operator+(s_points, s_points);
s_points operator-(s_points, s_points);
s_points foo(s_points p)
{
return p-42_sp+1_sp; // Put space before + here and GCC will accept the
code
}
I get the following error on return statement line above:
:9:14: error: unable to find numeric literal operator
'operator""_sp+1_sp'
9 | return p-42_sp+1_sp;
| ^~
Since ud-suffix is just an identifier in the grammar, it should not grab +
while parsing, which according to error is what it seems to be doing.
Here is this snippet on Compiler Explorer: https://godbolt.org/z/4bfs6P