Skip to content

Token pasting string constant to user defined literal throws invalidHashHash exception #168

Open
@bedw021

Description

@bedw021

Token pasting to string constants ("abc") and character constants ('c') currently generates an invalidHashHash exception:

#define NUM_CHAR(str) str##_numch

inline auto operator "" _numch(const char *ch, std::size_t size) noexcept -> std:size_t
{
  return size;
}

int main()
{
  auto x = "abc"_numch; // Valid expression
  auto y = NUM_CHAR("abc"); // Throws invalidHashHash exception, but expands to the same as previous line
}

Token pasting A ## B should be allowed if A is a string or character constant, and B is a name, as B may be a literal that operates on A.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions