https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112423

            Bug ID: 112423
           Summary: A weird reported diagnosis about user-defined-literal
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

#include <iostream>

struct A{
    void foo(){}
};

A operator ""_to(const char* ptr){
    std::cout<< ptr;
    return A{};
}

int main(){
    123_to. foo();
}

The reported diagnosis is 
> unable to find numeric literal operator 'operator""_to.'

Well, "123_to." is a single preprocessing token(i.e. pp-number), which is then
converted to a token in translation phase 7([lex.phases] p1.7), however, the
pp-number is neither a valid integer-literal, floating-point-literal, nor a
user-defined-literal. The diagnosis implies "123_to." is parsed as a
user-defined-literal but a viable operator `operator""_to.` cannot be found,
which is wrong and misleading.
  • [Bug c++/112423] New: A weird r... xmh970252187 at gmail dot com via Gcc-bugs

Reply via email to