Skip to content

Seemingly incorrect treatment of constexpr member functions in modules #107673

Closed
@kamrann

Description

@kamrann

According to the standard, member functions defined within a class definition are implicitly inline in the global module, but not so within a module purview. However, the standard also states that constexpr member functions are implicitly inline, and in this case makes no exception for modules.

11.4.2/1 [class.mfct] - see also Note 1
9.2.6/1 [dcl.constexpr]

As such all constexpr member functions should be inline, regardless of modules. From what I can see, clang is not respecting this. I'm seeing linker errors for such member functions when using modules with shared libraries.

I believe the difference between clang and gcc seen here is fundamentally the cause. Clang is generating code for a function marked constexpr but not for one marked inline constexpr, yet if I'm interpreting the standard correctly these cases should be equivalent.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header ModulesconstexprAnything related to constant evaluationrelease:backport

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions