This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4506. source_location is explicitly unspecified if is constexpr or not

Section: 17.8.2 [support.srcloc.class] Status: New Submitter: Hana Dusíková Opened: 2025-12-27 Last modified: 2026-01-17

Priority: Not Prioritized

View all issues with New status.

Discussion:

Basically in 17.8.2.1 [support.srcloc.class.general] following p1 there is a note from Jens from six years ago which says (emphasis mine):

[Note 1: The intent of source_location is to have a small size and efficient copying. It is unspecified whether the copy/move constructors and the copy/move assignment operators are trivial and/or constexpr. — end note]

But also reflection's std::meta::source_location_of returns it by value and is consteval. This means source_location needs to be specified to constexpr. And good news is ... all three major implementations have it constexpr implicitly.

Options are (from my perspective) to remove that part of the note "and/or constexpr" and just call it a day, or add

constexpr source_location(const source_location&) = default;
constexpr source_location(source_location&&) noexcept = default;
constexpr source_location& operator=(const source_location&) = default;
constexpr source_location& operator=(source_location&&) noexcept = default;

AFAIK this is how to explicitly say it must be constexpr but it can still be trivial, see demo.

Proposed resolution: