From 55a4bb745b155c32d20e8fe4e31c1e71ef176ac9 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Thu, 1 Oct 2026 12:06:02 +0800 Subject: [PATCH 1/6] CWG 2355 Deducing noexcept-specifiers --- src/cmd_line.c | 10 +--------- src/target.h | 6 ------ src/templates.c | 9 ++------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/cmd_line.c b/src/cmd_line.c index cf2b819cd1..be7204980a 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -3237,7 +3237,6 @@ option values if they were not already set by a command line option. exc_spec_in_func_type = TRUE; } /* if */ #endif /* EXC_SPEC_IN_FUNC_TYPE_ENABLING_POSSIBLE */ - deduction_from_exc_spec_allowed = FALSE; if (!option_kind_used[(int)optk_aligned_new]) { overaligned_allocation_enabled = TRUE; } /* if */ @@ -5928,13 +5927,7 @@ before this routine is called. warn_on_deduced_return_types = TRUE; } /* if */ } /* if */ - if (cpp17_mode) { - /* g++ and clang allow deduction from the noexcept flag of a function - parameter. */ - if (exc_spec_in_func_type) { - deduction_from_exc_spec_allowed = TRUE; - } /* if */ - } else { + if (!cpp17_mode) { /* g++ and clang do not implement this as a DR in C++14 mode. Note that clang has this disabled by default even in C++17 mode (as of 6.0.1). But we don't have a separate option to enable this, so we still @@ -13281,7 +13274,6 @@ variables declared in cmd_line.h. implicit_noexcept_enabled = FALSE; core_constant_expr_is_noexcept = FALSE; exc_spec_in_func_type = FALSE; - deduction_from_exc_spec_allowed = FALSE; delegating_constructors_enabled = FALSE; inheriting_constructors_enabled = FALSE; constexpr_enabled = FALSE; diff --git a/src/target.h b/src/target.h index 93643b367c..e27135be22 100644 --- a/src/target.h +++ b/src/target.h @@ -926,12 +926,6 @@ EXTERN_THREAD a_boolean semantically. This flag is TRUE if the C++17 semantics should be implemented. */ -EXTERN_THREAD a_boolean - deduction_from_exc_spec_allowed; - /* TRUE if a template parameter can be deduced from - the noexcept flag of a parameter of function - type. */ - EXTERN_THREAD a_boolean assume_references_cannot_be_null; /* If TRUE, C++ references are assumed never to have diff --git a/src/templates.c b/src/templates.c index 1545357144..cadd07132a 100644 --- a/src/templates.c +++ b/src/templates.c @@ -13889,9 +13889,6 @@ A nontype template parameter is potentially being deduced from a noexcept specifier. For example: template void f(int (*)() noexcept(B)); - -This is currently nonstandard, but accepted by GCC and Clang, and the omission -in the standard is perhaps accidental. */ { a_boolean match = FALSE; @@ -13907,11 +13904,9 @@ in the standard is perhaps accidental. } else { /* Check the exception specification. */ a_constant_ptr t_cp = t_esp->variant.noexcept_arg; - if (deduction_from_exc_spec_allowed && - (flags & MTT_ALLOW_STRICTER_NOEXCEPT) == 0 && + if ((flags & MTT_ALLOW_STRICTER_NOEXCEPT) == 0 && !constant_bool_value_known_at_compile_time(t_cp)) { - /* Some compilers allow deduction from the noexcept flag of a function - type. Do this deduction, if needed. */ + /* Perform deduction from the noexcept flag of a function type. */ a_constant_ptr cp; a_boolean cp_is_local = FALSE; if (esp != NULL && esp->variant.noexcept_arg != NULL) { From 9f5428e61a0cef81742f521c6cae6c46db521d41 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Fri, 2 Oct 2026 09:47:01 +0800 Subject: [PATCH 2/6] Restore deduction_from_exc_spec_allowed and make it default to TRUE --- src/cmd_line.c | 2 ++ src/target.h | 6 ++++++ src/templates.c | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd_line.c b/src/cmd_line.c index be7204980a..a1fc4154cb 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -3237,6 +3237,7 @@ option values if they were not already set by a command line option. exc_spec_in_func_type = TRUE; } /* if */ #endif /* EXC_SPEC_IN_FUNC_TYPE_ENABLING_POSSIBLE */ + deduction_from_exc_spec_allowed = microsoft_version >= 1951; if (!option_kind_used[(int)optk_aligned_new]) { overaligned_allocation_enabled = TRUE; } /* if */ @@ -13274,6 +13275,7 @@ variables declared in cmd_line.h. implicit_noexcept_enabled = FALSE; core_constant_expr_is_noexcept = FALSE; exc_spec_in_func_type = FALSE; + deduction_from_exc_spec_allowed = TRUE; delegating_constructors_enabled = FALSE; inheriting_constructors_enabled = FALSE; constexpr_enabled = FALSE; diff --git a/src/target.h b/src/target.h index e27135be22..93643b367c 100644 --- a/src/target.h +++ b/src/target.h @@ -926,6 +926,12 @@ EXTERN_THREAD a_boolean semantically. This flag is TRUE if the C++17 semantics should be implemented. */ +EXTERN_THREAD a_boolean + deduction_from_exc_spec_allowed; + /* TRUE if a template parameter can be deduced from + the noexcept flag of a parameter of function + type. */ + EXTERN_THREAD a_boolean assume_references_cannot_be_null; /* If TRUE, C++ references are assumed never to have diff --git a/src/templates.c b/src/templates.c index cadd07132a..41a501ed64 100644 --- a/src/templates.c +++ b/src/templates.c @@ -13904,7 +13904,8 @@ specifier. For example: } else { /* Check the exception specification. */ a_constant_ptr t_cp = t_esp->variant.noexcept_arg; - if ((flags & MTT_ALLOW_STRICTER_NOEXCEPT) == 0 && + if (deduction_from_exc_spec_allowed && + (flags & MTT_ALLOW_STRICTER_NOEXCEPT) == 0 && !constant_bool_value_known_at_compile_time(t_cp)) { /* Perform deduction from the noexcept flag of a function type. */ a_constant_ptr cp; From 61c0c5375f193af1737a7cfc2981aec6e2dc7a64 Mon Sep 17 00:00:00 2001 From: Daveed Vandevoorde Date: Fri, 2 Oct 2026 09:48:11 +0800 Subject: [PATCH 3/6] Add Changes entry --- src/Changes | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Changes b/src/Changes index 3b683cef04..1aa9609211 100644 --- a/src/Changes +++ b/src/Changes @@ -1,3 +1,12 @@ +10/1/26 [GH #197] +Deducing noexcept-specifiers + +Previously, the front end emulated Clang and GCC's ability to deduce simple dependent +noexcept-specifiers (see the entry for EDGcpfe/18317 of 9/6/17). Meanwhile, the standard +has been changed through Core issue 2355 to make that behavior standard-mandated. +It is now the default behavior, except in Microsoft mode with microsoft_version < 1951. + + Version 7.0, September 28, 2026 9/15/26 [EDGcpfe/28958] From d138346d5d4ce70eca247267be9aef93942bffaf Mon Sep 17 00:00:00 2001 From: cpplearner Date: Fri, 2 Oct 2026 18:32:56 +0800 Subject: [PATCH 4/6] Test relevant configurations --- tests/tests/cwg/2355a.sft.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tests/cwg/2355a.sft.cpp b/tests/tests/cwg/2355a.sft.cpp index 300a2f376b..0d618bc057 100644 --- a/tests/tests/cwg/2355a.sft.cpp +++ b/tests/tests/cwg/2355a.sft.cpp @@ -1,4 +1,5 @@ -//options_all:--c++20 -tused -A +//options:--c++17 -A:--c++17 --gn 160200:--c++17 --clang_version 230100:--ms_c++17 --microsoft_version 1950;fn:--ms_c++17 --microsoft_version 1951:--c++14 -A;fn:--c++14 --gn 160200;fn:--c++14 --clang_version 230100;fn:--ms_c++14 --microsoft_version 1950;fn:--ms_c++14 --microsoft_version 1951;fn +//options_all:-tused template void f1(void (*)() noexcept(E)); void g1(); From d7ab1773d92ad8bdda5060933243a1f0b0935c1c Mon Sep 17 00:00:00 2001 From: cpplearner Date: Fri, 2 Oct 2026 18:23:12 +0800 Subject: [PATCH 5/6] Wrap lines to fit in 80 columns --- src/Changes | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Changes b/src/Changes index 1aa9609211..79bcd59a6c 100644 --- a/src/Changes +++ b/src/Changes @@ -1,10 +1,11 @@ 10/1/26 [GH #197] Deducing noexcept-specifiers -Previously, the front end emulated Clang and GCC's ability to deduce simple dependent -noexcept-specifiers (see the entry for EDGcpfe/18317 of 9/6/17). Meanwhile, the standard -has been changed through Core issue 2355 to make that behavior standard-mandated. -It is now the default behavior, except in Microsoft mode with microsoft_version < 1951. +Previously, the front end emulated Clang and GCC's ability to deduce simple +dependent noexcept-specifiers (see the entry for EDGcpfe/18317 of 9/6/17). +Meanwhile, the standard has been changed through Core issue 2355 to make that +behavior standard-mandated. It is now the default behavior, except in +Microsoft mode with microsoft_version < 1951. Version 7.0, September 28, 2026 From c654eacb40a7d35d17cd503e1c448508dd0e5ad0 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Fri, 2 Oct 2026 18:29:35 +0800 Subject: [PATCH 6/6] Remove test expectations for CWG 2355 tests --- tests/expectations/edg_x86_32/cwg.log | 3 --- tests/expectations/edg_x86_32_cp/cwg.log | 3 --- tests/expectations/edg_x86_64/cwg.log | 3 --- tests/expectations/edg_x86_64_cp/cwg.log | 3 --- 4 files changed, 12 deletions(-) diff --git a/tests/expectations/edg_x86_32/cwg.log b/tests/expectations/edg_x86_32/cwg.log index 4a252b98ce..73bb0931f6 100644 --- a/tests/expectations/edg_x86_32/cwg.log +++ b/tests/expectations/edg_x86_32/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_32_cp/cwg.log b/tests/expectations/edg_x86_32_cp/cwg.log index 6d9dcaf602..55af429f01 100644 --- a/tests/expectations/edg_x86_32_cp/cwg.log +++ b/tests/expectations/edg_x86_32_cp/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_64/cwg.log b/tests/expectations/edg_x86_64/cwg.log index 4a252b98ce..73bb0931f6 100644 --- a/tests/expectations/edg_x86_64/cwg.log +++ b/tests/expectations/edg_x86_64/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_64_cp/cwg.log b/tests/expectations/edg_x86_64_cp/cwg.log index 6d9dcaf602..55af429f01 100644 --- a/tests/expectations/edg_x86_64_cp/cwg.log +++ b/tests/expectations/edg_x86_64_cp/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: