Skip to content

[Modules] Stack dump/not constexpr while instantiating hidden friend #54457

Closed
@JohelEGP

Description

@JohelEGP

See stack dump at https://godbolt.org/z/zeaqzTPjq. When the return type is the injected-class-name, its evaluation isn't considered a constant expression; see https://godbolt.org/z/zTEvYxx6x. GCC accepts them: https://godbolt.org/z/c7nq4dGE3, https://godbolt.org/z/YzaM56G1G.
mod.cpp:

export module mod;

export template<typename StandardCharT, int N>
struct basic_symbol_text {
  template<int N2>
  constexpr friend basic_symbol_text operator+(
    const basic_symbol_text&, const basic_symbol_text<char, N2>&) noexcept
  {
    return basic_symbol_text<StandardCharT, 1>{};
  }
};

constexpr auto xxx = basic_symbol_text<char, 1>{} + basic_symbol_text<char, 1>{};
export module mod;

export template<typename StandardCharT, int N>
struct basic_symbol_text {
  template<int N2>
  constexpr friend basic_symbol_text operator+(
    const basic_symbol_text&, const basic_symbol_text<char, N2>&) noexcept
  {
    return basic_symbol_text{};
  }
};

constexpr auto xxx = basic_symbol_text<char, 1>{} + basic_symbol_text<char, 1>{};

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"clang:modulesC++20 modules and Clang Header ModulescrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions