Menu

operator with no argeuments and a requires claus fail to parse

2023-10-10
2023-10-10
  • dominik nussbaumer

    I noticed that operators with no arguments in classes fail to parse when a requires clause is used. The current development version also fails to parse this.

    Here are two failing minimal examples and one that parses fine.

    template <typename T> struct test {
      operator int() requires true { return 0; }
    };
    

    example.cpp:2:32: error: syntax error: operator [syntaxError]
    operator int() requires true { return 0; }
    ^
    Active checkers: There was critical errors

    template <typename T> struct test {
      bool operator()() requires true { return true; }
    };
    

    example.cpp:4:36: error: syntax error: operator [syntaxError]
    bool operator()() requires true { return true; }
    ^
    Active checkers: There was critical errors

    template <typename T> struct test {
       bool operator()(int a) requires true { return true; }
    };
    

    The last one parses fine.

     

    Last edit: dominik nussbaumer 2023-10-10
  • CHR

    CHR - 2023-10-10

    Thanks for reporting, see https://trac.cppcheck.net/ticket/10251

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.