On Thu, 29 Jan 2026 at 16:57, vspefs <[email protected]> wrote:
>
> C++26 contracts implementation requires modifications to source_location
> header file. The logic is added but not triggered due to not defining
> __glibcxx_want_contracts before including the internal version header.
> This patch fixes this.

Thanks for pointing out the problem. This is not a correct change though.

This will cause <source_location> to define the __cpp_lib_contracts
macro, but the C++26 draft says only the <version> and <contracts>
headers define that macro.

The right fix is to change the #ifdef lines to check
__glibcxx_contracts instead. I'll make that change and add a test.

>
> libstdc++-v3/ChangeLog:
>
> * include/std/source_location: Define __glibcxx_want_contracts.
>
> Signed-off-by: Xie Han <[email protected]>
> ---
>  libstdc++-v3/include/std/source_location | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libstdc++-v3/include/std/source_location 
> b/libstdc++-v3/include/std/source_location
> index 170753fdde2..08d9779fa1d 100644
> --- a/libstdc++-v3/include/std/source_location
> +++ b/libstdc++-v3/include/std/source_location
> @@ -30,6 +30,7 @@
>  #define _GLIBCXX_SRCLOC 1
>
>  #define __glibcxx_want_source_location
> +#define __glibcxx_want_contracts
>  #include <bits/version.h>
>
>  #if __cpp_lib_source_location // C++ >= 20 && builtin_source_location
> --
> 2.52.0
>
>

Reply via email to