In the 'RTL SSA Access Lists' subsection of
GCC's documentation, an example of code with
an 'if'...'else' structure is given. The
given list of the full list of accesses is
said to include "use of the ebb4's R phi
definition of R by B". That cannot be true
because B is in the first substatement of the
'if' statement, whereas ebb4 is the second
substatement. First and second substatements
are mutually exclusive: there is no path to
B that goes through the degenerate phi node
of ebb4.
Previously code for the error message about VMAT_ELEMENTWISE and
VMAT_STRIDED_SLP could never be reached because it was dominated by
the logic for the unsupported access type for masked load.
This change reverses the two checks so that the more specific case
comes first.
gcc/ChangeLog:
* tree-vect-stmts.cc (vectorizable_load): Swap order of failure
message checks.
Martin Uecker [Sat, 7 Mar 2026 15:28:00 +0000 (16:28 +0100)]
c: Mark derived types variably-modified after struct/union completion [PR123424]
When structure types are completed and are variably-modified, we
need to make sure that C_TYPE_VARIABLY_MODIFIED is updated also
for derived types. For derived types which are not updated and
remain TYPE_STRUCTURAL_EQUALITY_P, we do recursion when checking
the bit instead. This change then fixes also a weird corner
case when forming composite types of mutually recursively
defined types.
We do not update other structure or union type that end up
with variably modified pointers, as it is not clear this is
needed and also needs further analysis.
Eric Botcazou [Mon, 23 Mar 2026 21:01:52 +0000 (22:01 +0100)]
Ada: Fix crash on instantiation in separate package body
This is an old regression present on all active branches for a quite unusual
setup where a generic package is declared and instantiated in a subunit, and
which comes from a thinko in the Has_Body.Find_Body routine of Sem_Elab.
Eric Botcazou [Mon, 23 Mar 2026 20:48:52 +0000 (21:48 +0100)]
Ada: Fix instantiation failure with formal array type after formal package
This comes from a confusion in the mapping maintained between formal and
actual parameters of the instantiation caused by the equivalent mapping
maintained for the instantiation of the formal package. The change just
removes the offending lines, which do not seem to serve any useful purpose.
gcc/ada/
PR ada/124606
* sem_ch12.adb (Find_Actual_Type): Rename formal parameter.
(Map_Formal_Package_Entities): Do not register base types.
gcc/testsuite/
* gnat.dg/generic_inst19.adb: New test.
Richard Biener [Mon, 23 Mar 2026 09:51:00 +0000 (10:51 +0100)]
tree-optimization/124599 - compile-time regression with PRE
The following fixes the reported compile-time regression after the
PRE change to properly track reference expressions in r16-8128-g5f1024922d3f67.
The issue is that the VN reference lookup code performs alias walks and
those are made quadratic for the transition from one VUSE to another
when that involves multiple translation steps. The error was to make
the VUSE part of the expression, but it is really part of the value.
So the following patch reverts this change, fixing the issue.
PR tree-optimization/124599
* tree-ssa-pre.cc (compute_avail): Make the VUSE in the
PRE reference expression part of the value again.
(phi_translate_1): Likewise.
Jakub Jelinek [Mon, 23 Mar 2026 11:10:02 +0000 (12:10 +0100)]
configure: Further {gas,gnu_ld}{,_flag} fixes [PR124547]
Andreas mentioned in the PR that {gas,gnu_ld}_flag vars should be only
ever used in configure.ac before . config.gcc and I agree with that.
config.gcc initializes the {gas,gnu_ld} vars to {gas,gnu_ld}_flag, then
for some triplets has gas=yes and/or gnu_ld=yes and in some rare cases
(for targets which basically require people to use --with{,out}-gnu-{as,ld})
x$gas = xyes/x$gnu_ld = xyes/x$gas != xyes/x$gnu_ld != xyes tests.
So, the following patch uses just what comes up from config.gcc from that
point onward (so, the user requested setting (which can be now empty if
unknown) possibly overridden by triplet). With the exception of solaris
(which does what it did before PR124547, i.e. always probe linker and
assembler) and the fallback case of checking gas/ld version if still unset
(but that in this patch only affects targets which don't override it
by triplet, i.e. targets which typically have a choice between GNU binutils
and some proprietary ones).
2026-03-23 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/124547
* configure.ac: After config.gcc inclusion use or set only gas instead
of gas_flag and gnu_ld instead of gnu_ld_flag.
* config.gcc: Document possibility of gas_flag or gnu_ld_flag being
empty.
* acinclude.m4 (gcc_GAS_FLAGS): Use gas instead of gas_flag.
(gcc_AC_INITFINI_ARRAY): Likewise. Use gnu_ld instead of gnu_ld_flag.
* configure: Regenerate.
libgfortran: Disable caf_shmem without usable process-shared pthreads [PR124512]
Use a compile-time usability probe for the process-shared pthread API
required by caf_shmem and only build libcaf_shmem when that probe succeeds.
caf_shmem needs process-shared pthread primitives that are visible through
the default pthread headers. AX_PTHREAD already established the baseline
pthread flags; this additional check only verifies that the specific
process-shared API surface is usable for caf/shmem/thread_support.c.
PR fortran/124512
libgfortran/ChangeLog:
* Makefile.am: Adjust the dependencies.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add new check.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Andrew Pinski [Sat, 21 Mar 2026 19:37:24 +0000 (12:37 -0700)]
x86: Mark the x86 va_builtins as nothrow and leaf [PR124597]
So all of the va_builtins are marked as nothrow and leaf but
the x86 backend builds the va builtins without this.
This causes both missed optimizations and in some cases
more work needs to be done by the middle-end handling of
these builtins.
This marks all of the x86 va builtins function decls as both
nothrow and leaf.
Bootstrapped and tested on x86_64-linux-gnu.
PR target/124597
gcc/ChangeLog:
* config/i386/i386-builtins.cc (ix86_init_builtins_va_builtins_abi):
Also add nothrow and leaf attributes to the va builtins.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sat, 21 Mar 2026 20:16:17 +0000 (13:16 -0700)]
gimple-fold: Fix folding of va_end with maybe throw builtin [PR124597]
The problem here is when we are replacing the va_end with a GIMPLE_NOP,
gsi_replace is being called with true for updating the eh information.
This was a mistake; for most case this worked but with x86 backend
creating a function decl without nothrow on the VA_END, this caused
problems of not removing eh edge after removing the call. (The
x86 backend change is submitted in a different patch).
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/124597
gcc/ChangeLog:
* gimple-fold.cc (gimple_fold_builtin_stdarg): Correct the
eh_update argument to gsi_replace for the VA_END case.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sat, 21 Mar 2026 22:15:07 +0000 (15:15 -0700)]
sh: Fix modes on if_then_else [PR123852]
Inside the machine description of the sh target,
there are some modes missing on if_then_else rtl. This
causes an ICE during the vartrack pass where it is
creating a simplifying a subreg of that rtl.
This worked before r16-3067-g8e3239e3e92f3c where
simplify_gen_subreg would return NULL RTL on the
case where the mode was VOIDmode.
Anyways this is the obvious patch which adds the modes
on the if_then_else and now fixes the Ada and algol68
building (and some other code).
Tested by Doko on sh-linux-gnu and the Ada and algol68
langauges enabled.
Pushed as obvious.
PR target/123852
gcc/ChangeLog:
* config/sh/sh.md (movsicc_t_false): Add the SImode
on the if_then_else.
(movsicc_t_true): Likewise.
(negsi_cond): Likewise.
(negdi_cond): Add the DImode on the if_then_else.
(bst_m2a): Add the QImode on the if_then_else.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jose E. Marchesi [Sat, 21 Mar 2026 12:20:36 +0000 (13:20 +0100)]
a68: avoid libga68 dependency on libm
Using some of the operators and routines in the standard prelude lead
to a dependency on standard system math routines, usually available in
libm. This is the case for sin, cos, etc.
If no such operator/routine is used by the user program, however, the
dependency should not be there. We recently implemented some parts of
libga68 in Algol 68, and these use the entier operator. Using this
operator drags in a dependency on floor, floorf and floorl via some
GCC built-ins.
This patch adds the gnulib implementation of floor, floorl and floorf
to libga68.
Tested in x86_64-pc-linux-gnu, in both -m64 and -m32 modes.
Tested in i686-pc-linux-gnu.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
libga68/ChangeLog
* ga68-math.c: New file.
* floor.c: Imported from gnulib.
* configure.ac: Do not check for libm.
* Makefile.am (libga68_la_SOURCES): Add ga68-match.c.
* Makefile.in (am_libga68_la_OBJECTS): Regenerate.
* configure (ac_res): Likewise.
Matthias Kretz [Wed, 11 Feb 2026 14:19:17 +0000 (15:19 +0100)]
libstdc++: Implement [simd] for C++26
This implementation differs significantly from the
std::experimental::simd implementation. One goal was a reduction in
template instantiations wrt. what std::experimental::simd did.
Design notes:
- bits/vec_ops.h contains concepts, traits, and functions for working
with GNU vector builtins that are mostly independent from std::simd.
These could move from std::simd:: to std::__vec (or similar). However,
we would then need to revisit naming. For now we kept everything in
the std::simd namespace with __vec_ prefix in the names. The __vec_*
functions can be called unqualified because they can never be called
on user-defined types (no ADL). If we ever get simd<UDT> support this
will be implemented via bit_cast to/from integral vector
builtins/intrinsics.
- bits/simd_x86.h extends vec_ops.h with calls to __builtin_ia32_* that
can only be used after uttering the right GCC target pragma.
- basic_vec and basic_mask are built on top of register-size GNU vector
builtins (for now / x86). Any larger vec/mask is a tree of power-of-2
#elements on the "first" branch. Anything non-power-of-2 that is
smaller than register size uses padding elements that participate in
element-wise operations. The library ensures that padding elements
lead to no side effects. The implementation makes no assumption on the
values of these padding elements since the user can bit_cast to
basic_vec/basic_mask.
Implementation status:
- The implementation is prepared for more than x86 but is x86-only for
now.
- Parts of [simd] *not* implemented in this patch:
- std::complex<floating-point> as vectorizable types
- [simd.permute.dynamic]
- [simd.permute.mask]
- [simd.permute.memory]
- [simd.bit]
- [simd.math]
- mixed operations with vec-mask and bit-mask types
- some conversion optimizations (open questions wrt. missed
optimizations in the compiler)
- This patch implements P3844R3 "Restore simd::vec broadcast from int",
which is not part of the C++26 WD draft yet. If the paper does not get
accepted the feature will be reverted.
- This patch implements D4042R0 "incorrect cast between simd::vec and
simd::mask via conversion to and from impl-defined vector types" (to be
published once the reported LWG issue gets a number).
- The standard feature test macro __cpp_lib_simd is not defined yet.
Tests:
- Full coverage requires testing
1. constexpr,
2. constant-propagating inputs, and
3. unknown (to the optimizer) inputs
- for all vectorizable types
* for every supported width (1–64 and higher)
+ for all possible ISA extensions (combinations)
= with different fast-math flags
... leading to a test matrix that's far out of reach for regular
testsuite builds.
- The tests in testsuite/std/simd/ try to cover all of the API. The
tests can be build in every combination listed above. Per default only
a small subset is built and tested.
- Use GCC_TEST_RUN_EXPENSIVE=something to compile the more expensive
tests (constexpr and const-prop testing) and to enable more /
different widths for the test type.
- Tests can still emit bogus -Wpsabi warnings (see PR98734) which are
filtered out via dg-prune-output.
Benchmarks:
- The current implementation has been benchmarked in some aspects on
x86_64 hardware. There is more optimization potential. However, it is
not always clear whether optimizations should be part of the library
if they can be implemented in the compiler.
- No benchmark code is included in this patch.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Add simd headers.
* include/Makefile.in: Regenerate.
* include/bits/version.def (simd): New.
* include/bits/version.h: Regenerate.
* include/bits/simd_alg.h: New file.
* include/bits/simd_details.h: New file.
* include/bits/simd_flags.h: New file.
* include/bits/simd_iterator.h: New file.
* include/bits/simd_loadstore.h: New file.
* include/bits/simd_mask.h: New file.
* include/bits/simd_mask_reductions.h: New file.
* include/bits/simd_reductions.h: New file.
* include/bits/simd_vec.h: New file.
* include/bits/simd_x86.h: New file.
* include/bits/vec_ops.h: New file.
* include/std/simd: New file.
* testsuite/std/simd/arithmetic.cc: New test.
* testsuite/std/simd/arithmetic_expensive.cc: New test.
* testsuite/std/simd/create_tests.h: New file.
* testsuite/std/simd/creation.cc: New test.
* testsuite/std/simd/creation_expensive.cc: New test.
* testsuite/std/simd/loads.cc: New test.
* testsuite/std/simd/loads_expensive.cc: New test.
* testsuite/std/simd/mask2.cc: New test.
* testsuite/std/simd/mask2_expensive.cc: New test.
* testsuite/std/simd/mask.cc: New test.
* testsuite/std/simd/mask_expensive.cc: New test.
* testsuite/std/simd/reductions.cc: New test.
* testsuite/std/simd/reductions_expensive.cc: New test.
* testsuite/std/simd/shift_left.cc: New test.
* testsuite/std/simd/shift_left_expensive.cc: New test.
* testsuite/std/simd/shift_right.cc: New test.
* testsuite/std/simd/shift_right_expensive.cc: New test.
* testsuite/std/simd/simd_alg.cc: New test.
* testsuite/std/simd/simd_alg_expensive.cc: New test.
* testsuite/std/simd/sse_intrin.cc: New test.
* testsuite/std/simd/stores.cc: New test.
* testsuite/std/simd/stores_expensive.cc: New test.
* testsuite/std/simd/test_setup.h: New file.
* testsuite/std/simd/traits_common.cc: New test.
* testsuite/std/simd/traits_impl.cc: New test.
* testsuite/std/simd/traits_math.cc: New test.
Nathaniel Shead [Thu, 19 Mar 2026 11:58:11 +0000 (22:58 +1100)]
c++/modules: Support section attributes [PR122786]
This is a minimal fix to not just silently drop the section attribute on
stream-in. Ideally we should be using cplus_decl_attributes for this,
but it's not yet ready for modules (many attributes behave weirdly when
applied not during parsing). We should also be checking for
incompatible sections on stream-in in is_matching_decl, but that would
also be better handled more generally so I'm leaving that out of this
patch.
Instead this minimally fixes the issue by just re-applying the section
name from the attributes we've streamed in.
PR c++/122786
gcc/cp/ChangeLog:
* module.cc (trees_in::decl_value): Set section name from
attribute.
gcc/testsuite/ChangeLog:
* g++.dg/modules/attrib-5_a.C: New test.
* g++.dg/modules/attrib-5_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Nathaniel Shead [Thu, 19 Mar 2026 11:56:20 +0000 (22:56 +1100)]
c++/modules: Handle maybe_unused on PARM_DECLs [PR124483]
The [[maybe_unused]] attribute works by marking relevant entities as
TREE_USED, and DECL_READ_P for vars and parms. But modules streaming
typically clears this flag unless reading a definition. This patch sets
it back again when we see this attribute applied to a parameter.
PR c++/124483
gcc/cp/ChangeLog:
* module.cc (trees_in::fn_parms_init): Set TREE_USED and
DECL_READ_P for parameters deliberately marked unused.
gcc/testsuite/ChangeLog:
* g++.dg/modules/attrib-4_a.C: New test.
* g++.dg/modules/attrib-4_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Tobias Burnus [Thu, 19 Mar 2026 22:55:56 +0000 (22:55 +0000)]
openmp: sorry instead of ICE for unimplemented mapper with iterator [PR122866]
Support for iterators on mapper functions is an OpenMP 5.2
feature that is not implemented yet. Presently attempting to use
this feature results in an ICE; let's make it a more user-friendly
"sorry" until we get around to implementing this.
gcc/ChangeLog
PR c/122866
* gimplify.cc (omp_instantiate_mapper): Give a sorry if there are
iterators.
Eric Botcazou [Fri, 20 Mar 2026 21:18:54 +0000 (22:18 +0100)]
Ada: Fix interaction between overloading and types with implicit dereference
The overall strategy for types declared with implicit dereference is to add
two interpretations for every name, the direct one and the one corresponding
to the generalized reference. But the two interpretations are not always
preserved through the analysis and, more importantly, the resolution stops
at the first couple of interpretations for such a name, disregarding more
traditional overloading of specific names.
The change makes sure that the two interpretation are preserved through the
analysis, and implements the proper resolution of traditionally overloaded
names in the presence of types with implicit dereference. It also performs
some streamlining in the common processing of overloaded nodes in Resolve.
gcc/ada/
PR ada/120669
* sem_ch4.adb (Analyze_Explicit_Dereference): Remove interpretations
of the prefix only if they are of access types.
(Analyze_One_Call.Indicate_Name_And_Type): Check for an implicit
dereference only after indicating the name and type of the call.
* sem_ch5.adb (Analyze_Assignment): Do not remove interpretations
for the LHS if they are for a type with implicit dereference.
* sem_res.adb (Resolve): Streamline the processing of overloaded
nodes once an interpretation is picked for them. Add a specific
handling for additional interpretations for generalized references.
(Resolve_Explicit_Dereference): Remove interpretations of the prefix
only if they are of access types.
(Is_Ambiguous_Operand): Skip the direct interpretation for a limited
type that has implicit dereference.
* sem_type.adb (Add_One_Interp): Set the name of the first entry of
the table of interpretations in more cases.
Marek Polacek [Thu, 19 Mar 2026 13:33:15 +0000 (09:33 -0400)]
c++/reflection: ICE with lifetime extension of consteval-only [PR124575]
Here we ICE in output_constant because we attempt to emit the temporary
created for lifetime extension of a consteval-only expression. Like
other consteval-only variables, the temporary also has to be marked
DECL_EXTERNAL so that we don't emit it.
I tried to do the setting in make_temporary_var_for_ref_to_temp, but
then we ICE in set_decl_context_in_fn.
PR c++/124575
gcc/cp/ChangeLog:
* call.cc (set_up_extended_ref_temp): If var is consteval-only,
mark it DECL_EXTERNAL.
gccrs: Move cli inner attribute injection to injection
Inner attribute injection was not within the injection function where
the other things get injected within a crate.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Use additional
cli attributes for the injection function. Move additional attribute
injection from here...
(Session::injection): ... to here.
* rust-session-manager.h: Update injection fonction prototype.
no_std is a builtin attribute required for rust-for-linux but was
missing from the builtin attribute list and instead considered an unknown
attribute macro invocation.
gcc/rust/ChangeLog:
* util/rust-attributes.cc: Add no_std to list of builtin attributes.
The compiler was accepting `#![no_core]` without requiring
`#![feature(no_core)]`, silently treating an unstable attribute
as stable. Gate it via check_no_core_attribute, consistent with
how other experimental attributes are handled.
Harishankar [Fri, 27 Feb 2026 01:43:10 +0000 (07:13 +0530)]
gccrs: resolve: Fix ICE on ambiguous glob re-exports
This patch adds an ambiguity check in 'finalize_rebind_import'.
If a Definition is ambiguous, it emits a proper error diagnostic
instead of crashing, consistent with rustc's behavior(verified)
Fixes Rust-GCC/gccrs#4411
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import): Add ambiguity
check before calling get_node_id() on glob import definitions.
gccrs: Use custom error type for enum variants parsing
gcc/rust/ChangeLog:
* parse/rust-parse-error.h (struct EnumVariant): Add error for enum
variant.
* parse/rust-parse-impl.hxx: Use new error type instead of nullptr.
* parse/rust-parse.h: Update function prototype.
* checks/lints/rust-lint-unused-var.cc (starts_with_underscore): Add
function to detect underscore within symbol name.
(check_decl): Call new function for underscore checking.
jayant chauhan [Sat, 14 Feb 2026 15:44:21 +0000 (21:14 +0530)]
gccrs: expand: Fix ICE on unimplemented RustcEncodable/Decodable derives
When encountering `#[derive(RustcEncodable)]` or `RustcDecodable`, the
`DeriveVisitor` previously fell through to `rust_unreachable ()`,
causing an Internal Compiler Error.
This patch adds cases for these built-in macros to explicitly emit a
"sorry, unimplemented" message instead of crashing.
Fixes Rust-GCC#3951
gcc/rust/ChangeLog:
* expand/rust-derive.cc (DeriveVisitor::derive): Handle
`BuiltinMacro::RustcEncodable` and `BuiltinMacro::RustcDecodable`.
vibhatsu [Fri, 6 Feb 2026 07:47:32 +0000 (13:17 +0530)]
gccrs: refactor: use MacroInvocation's node id everywhere for consistency
gcc/rust/ChangeLog:
* ast/rust-macro.h: remove get_macro_node_id and propagate
MacroInvocation's node id through get_node_id for consistency
* util/rust-hir-map.cc (Mappings::insert_macro_invocation): replace
all get_macro_node_id calls with get_node_id calls
(Mappings::lookup_macro_invocation): likewise
(Mappings::insert_bang_proc_macro_invocation): likewise
(Mappings::lookup_bang_proc_macro_invocation): likewise
Jayant Chauhan [Fri, 16 Jan 2026 17:34:00 +0000 (23:04 +0530)]
gccrs: ast: Implement reconstruct() logic for Path hierarchy
This patch implements the `reconstruct` pattern for the `Path` hierarchy and its
constituents (segments, generic args, qualified paths).
Previously, derive expansion macros (like `derive(PartialEq)`) had to manually
rebuild paths field-by-field to ensure fresh NodeIDs. This change moves that
logic into the AST classes themselves, allowing paths to be deeply reconstructed
uniformly. This ensures that expanded code has unique NodeIDs, which is critical
for correct name resolution.
gcc/rust/ChangeLog:
* ast/rust-path.h (GenericArgsBinding::reconstruct): New method.
(GenericArg::reconstruct): New method.
(GenericArgs::reconstruct): New method.
(PathExprSegment::reconstruct): New method.
(PathInExpression::reconstruct): New method.
(TypePathSegmentGeneric::reconstruct_impl): New method.
(TypePathFunction::reconstruct): New method.
(TypePathSegmentFunction::reconstruct_impl): New method.
(QualifiedPathType::reconstruct): New method.
(QualifiedPathInExpression::reconstruct): New method.
(QualifiedPathInType::reconstruct_impl): New method.
* expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): Use path.reconstruct().
(EnumMatchBuilder::strukt): Use path.reconstruct().
Add a no_std attribute, when both no_std and no_core attributes are
missing, inject an external std crate.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Inject std crate
when both no_std and no_core attributes are missing.
* util/rust-attribute-values.h: Add no_std attribute value.
gccrs: Remove duplicated visit within early name res
Attribute content was checked twice within the early name resolution,
from outside the attribute and then using the default visitor. Remove
the first one visit. Also fix the wrong locus on trait resolution.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute):
Change from attribute locus to trait locus.
(Early::visit_attributes): Remove function.
(Early::visit): Remove functions.
* resolve/rust-early-name-resolver-2.0.h: Remove unused prototypes.
gccrs: Correctly emit warning on invalid attributes
We were emitting warning even on attribute that were then removed by
the cfgstrip pass. We cannot move the cfg strip pass before the attribute
checking because we need to first emit malformed input error messages.
This means the attribute checking pass must know if an attribute input
may be removed later down the line.
gcc/rust/ChangeLog:
* ast/rust-ast.cc (MetaItemPathExpr::to_attribute): Remove cast to
literal.
(AttrInputMetaItemContainer::separate_cfg_attrs): Remove PathExpr
specific code.
* expand/rust-cfg-strip.cc (expand_cfg_attrs): Remove the whole
attribute if condition's result is false.
* util/rust-attributes.cc (AttributeChecker::visit): Remove specific
code section for meta item container. Do not check input if
configuration does not match condition.
gcc/testsuite/ChangeLog:
* rust/compile/attr_malformed_path.rs: Filter existing test to x86_64
exclusively, add two new tests that appear when visiting the resulting
expression.
We will require expr within attribute input in the future in order to be
able to handle some nightly features. Even, the current macro attribute
input could be converted to an expression attribute input.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor
implementation.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-collector.h: Add function prototype.
* ast/rust-ast-visitor.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* ast/rust-ast.cc (Attribute::get_traits_to_derive): Handle EXPR
variant.
(AttrInputExpr::AttrInputExpr): Add constructor.
(AttrInputExpr::operator=): Add assignment operator implementation.
(AttrInputExpr::as_string): Add a string conversion member function.
(AttrInputExpr::accept_vis): Add visitor function.
* ast/rust-ast.h: Add EXPR type variant to AttrInput.
* util/rust-attributes.cc (check_doc_attribute): Handle expr variant.
* ast/rust-expr.h (class AttrInputExpr): Add class definition with
member function prototypes.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add empty
visitor implementation.
A crate is not a visitable and thus cannot be used with the debug
function. Until it is made visitable this commit provides a function
to dump the content of a crate.
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (debug): Add debug function which calls debug
on every crate field.
* ast/rust-ast-dump.h (debug): Add function prototype.
gccrs: Use Attribute node status for AttributeChecker
Remove attribute specific checking, use default ast visitor instead.
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::visit): Rename function
and make call to ast default visitor.
(AttributeChecker::check_attribute): Remove function.
* util/rust-attributes.h: Add function prototype.
Attribute have always been a bit weird, they were part of the AST but did
not have any visitor function, this create a lot of friction around them
as their input which may be an expression, a literal and even an
expression in the future didn't get visited properly during the different
passes of the compiler.
gcc/rust/ChangeLog:
* ast/rust-ast-full-decls.h (struct Attribute): Change from here...
(class Attribute): ...to a class here.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add a default
visit function for the attributes.
* ast/rust-ast-visitor.h: Add a proper visit function declaration for
attributes.
* ast/rust-ast.cc (Attribute::accept_vis): Add a function to accept a
visitor within the attributes.
* ast/rust-ast.h (struct Attribute): Add the accept_vis function
prototype.
(class Attribute): Rename from struct to class.
* expand/rust-derive.h: Add an empty implementation for visits to
prevent the visitor from recursing into the attributes.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add missing
implementation for attribute visit function. Add a check for derive
attributes that would have slipped through the passes.
* hir/rust-ast-lower-base.h: Add function prototype.
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
Split the function into two halves.
(Early::visit_derive_attribute): Specialized function from
visit_attribute for derive attributes.
(Early::visit_non_builtin_attribute): Likewise for non builtin
attributes.
(Early::visit): Rename visit_attributes to visit.
* resolve/rust-early-name-resolver-2.0.h (class Early): Update function
prototypes.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4212.rs: Update test with the new errors.
gccrs: Add crate_name and crate_type to attribute values
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::handle_crate_name): Use the new
constexpr instead of a raw string value.
* util/rust-attribute-values.h: Add crate_name and crate_type values.
gccrs: Move early gate feature store to it's own TU
Move the early feature gate store to it's own translation unit. This
will reduces the size of included headers within the parser.
gcc/rust/ChangeLog:
* Make-lang.in: Add new specific feature store file.
* checks/errors/feature/rust-feature-gate.cc (EarlyFeatureGateStore::get):
Move from here to rust-feature-store.cc.
(EarlyFeatureGateStore::add): Likewise.
(EarlyFeatureGateStore::get_error): Likewise.
(FeatureGate::check): Likewise.
* checks/errors/feature/rust-feature-gate.h (class EarlyFeatureGateStore):
Move class declaration to rust-feature-store.h header.
* parse/rust-parse.h: Change included header.
* checks/errors/feature/rust-feature-store.cc: New file.
* checks/errors/feature/rust-feature-store.h: New file.
gccrs: Collect early feature gating errors in a store
We use multiple parsers and can't retrieve all early feature gating
errors within the usual gating pass. This commit introduces a store to
collect all early gating errors in the same place from multiple parsers.
The features are then checked as usual within the feature gate checker.
gcc/rust/ChangeLog:
* checks/errors/feature/rust-feature-gate.cc (EarlyFeatureGateStore::get):
Add function to retrieve singleton instance.
(EarlyFeatureGateStore::add): New function to add an error and the
corresponding feature in the store.
(EarlyFeatureGateStore::get_error): Add new function to retrieve the
oldest error.
(FeatureGate::check): Update the function to retrieve the errors from
the store instead of getting it from the parameters.
* checks/errors/feature/rust-feature-gate.h (class EarlyFeatureGateStore):
Add a new class to collect all early feature gating errors.
* parse/rust-parse.h: Use store instead of keeping the errors within
the parser instance.
* rust-session-manager.cc (Session::compile_crate): Remove old early
error collection from the main parser.
* rust-system.h: Include queue header.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3661.rs: Add key_value_attribute feature to
prevent error on stringify macro.
* rust/compile/early_feature_gate_in_macro.rs: Add test to highlight
early feature gate error collection within macros.
Some nightly features change the parser's behavior, it may accepts syntax
that should be rejected when the feature is missing. But the complete
list of enabled features can only be found once the parsing is complete.
We should therefore not emit any error at parse time and instead collect
a potential error and emit it later during the feature gating step.
gcc/rust/ChangeLog:
* checks/errors/feature/rust-feature-gate.cc (FeatureGate::check):
Check all parse time errors.
* checks/errors/feature/rust-feature-gate.h: Update function prototype
with parse time errors.
* parse/rust-parse-impl-attribute.hxx: Collect potential gating error
with non literal attribute values. Remove error emission.
* parse/rust-parse.h: Add a function to gather potential feature gating
errors as well as a getter for collected errors.
* rust-session-manager.cc (Session::compile_crate): Retrieve potential
feature gating errors and check them later during the feature gating
step.
* util/rust-attributes.cc (check_export_name_attribute): Change
attribute checking error emission to prevent errors with macro inputs.
gcc/testsuite/ChangeLog:
* rust/compile/doc_macro.rs: Enable feature to use a macro within an
attribute input.
* rust/compile/parse_time_feature_gate.rs: New test.
rust-for-linux uses some nightly features that appeared with rust 1.50,
this patch provides a new mechanism dedicated to features required for
rfl that were not available back then.
gcc/rust/ChangeLog:
* checks/errors/feature/contrib/fetch: Bump version from 1.49.0 to
1.50.0. Change brace expansion to explicit file fetch.
* checks/errors/feature/rust-feature-defs.h: Regenerate.
* checks/errors/feature/contrib/copyright-stub.h: Add rfl include
directive.
* checks/errors/feature/rust-feature-defs-rfl.h: New file.
gccrs: Add early cfg strip step before feature collection
Features are now collected early rather than later during the feature
gating visitor. This requires the introduction of an early cfg strip
in order to collect #![cfg(xxxx), feature(yyyy)] correctly.
gcc/rust/ChangeLog:
* Make-lang.in: Add rust-early-cfg-strip object file.
* expand/rust-cfg-strip.h (expand_cfg_attrs): Declare function prototype.
* rust-session-manager.cc (Session::compile_crate): Reorder feature
collection and add early cfg strip.
* expand/rust-early-cfg-strip.cc: New file.
* expand/rust-early-cfg-strip.h: New file.
gccrs: Split feature collection from feature gating
Feature collection should happen before expansion because some feature
gating happens with macros. This commit does no move the feature
collection before the expansion pass, it simply split the collection part
from the gating part.
gcc/rust/ChangeLog:
* Make-lang.in: Add new feature collector file.
* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit):
Remove feature collection from gating visitor.
(FeatureGate::gate): Use features from the crate feature entity instead
of old class members.
* checks/errors/feature/rust-feature-gate.h: Get features from a
separate CrateFeatures struct instead of keeping them in the class.
* rust-session-manager.cc (Session::compile_crate): Collect features
before gating them.
* util/rust-attribute-values.h: Add feature attribute value.
* checks/errors/feature/rust-feature-collector.cc: New file.
* checks/errors/feature/rust-feature-collector.h: New file.
Owen Avery [Sat, 3 Jan 2026 00:16:24 +0000 (19:16 -0500)]
gccrs: Add wrapper class for automatic node cloning
This patch adds a wrapper class called Cloneable, which can be used to
automatically perform polymorphic copying. This should greatly reduce
the need for error-prone user defined copy constructors and assignment
operators.
As a demonstration/first step, this patch also uses Cloneable to
simplify the pattern nodes described in gcc/rust/ast/rust-pattern.h.
Jonathan Wakely [Fri, 9 Jan 2026 13:39:49 +0000 (13:39 +0000)]
libstdc++: Fix chrono::current_zone() for three-level names [PR122567]
chrono::current_zone() fails if /etc/localtime is a symlink to a zone
with three components, like "America/Indiana/Indianapolis", because we
only try to find "Indianapolis" and "Indiana/Indianapolis" but neither
of those is a valid zone name.
We need to try up to three components to handle all valid cases, such as
"UTC", "America/Indianapolis", and "America/Indiana/Indianapolis". It's
also possible that users could provide a custom tzdata.zi file which
includes zones with names using more than three levels, so loop over all
filename components of the path that /etc/localtime points to.
This also replaces std::filesystem::read_symlink with a plain readlink
call and find+substr operations on a std::string_view, which is
approximately twice as fast as using std::filesystem::path and
std::string.
By default we use a fixed char[128] buffer for readlink to write into,
but if that doesn't fit we use a std::string as a dynamic buffer that
grows as needed. We could use ::stat to find the exact length of the
symlink and avoid looping with an increasingly large std::string
capacity, but it's already expected to be rare for the char[128] buffer
to be exceeded, so needing to double the std::string capacity more than
once (i.e. to 512 or more) should be exceedingly rare. Adding a call to
::stat would perform a third filesystem operation when two readlink
calls should be sufficient for the vast majority of realistic cases.
One consequence of not using filesystem::path is that redundant
consecutive slashes in the pathname aren't automatically ignored, e.g.
/usr/share/zoneinfo/Europe//London worked fine with the old
implementation because we manually concatenated the path components,
i.e. "Europe" + '/' + "London". So that this continues to work there is
a new loop to remove redundant slashes from the string being processed.
That adds a slower, allocating path, but is unlikely to be needed in
practice (the systemd spec for /etc/localtime explicitly says it should
end with a time zone name, so "Europe//London" would be invalid anyway,
even if it points to a valid file). Again, this loop is expected to be
rare so optimizing this case further isn't important.
While manually testing this I noticed that we will interpret a bogus
symlink such as /usr/share/zoneinfo/America/Europe/London as a valid
timezone, even though it's a dangling symlink. We find a name match for
"Europe/London" before we get to the "America" component. This seems
unlikely to matter in practice, and was a pre-existing problem.
There's no testcase for current_zone() correctly handling three-level
names or symlinks with unusual targets. It cannot be tested without
changing the target of /etc/localtime which requires root access.
I'm still considering whether we want to cache the result of
current_zone(), either globally or in the tzdb object. Just returning a
cached variable takes 20-30ns instead of more than 700ns to access the
filesystem and read the symlink. Using ::lstat to check the symlink's
mtime would add some overhead though.
libstdc++-v3/ChangeLog:
PR libstdc++/122567
* src/c++20/tzdb.cc (tzdb::current_zone): Loop over all trailing
components of /etc/localtime path. Use readlink instead of
std::filesystem::read_symlink.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Tue, 17 Mar 2026 15:58:10 +0000 (15:58 +0000)]
libstdc++: Optimize fs::path::operator+=(const path&) alias check
Instead of a loop that compares &p to the address of each path
component, we can just do two pointer comparisons to see if &p is within
the contiguous array of components.
We don't need to make the same change to experimental::filesystem::path
because as noted in r15-9709-gbeb0ffd36eedf0 the TS implementation
doesn't attempt to optimize operator+= so doesn't care if the parameter
aliases *this.
libstdc++-v3/ChangeLog:
* src/c++17/fs_path.cc (path::operator+=): Use pointer
comparison to detect aliasing instead of a loop.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Wed, 18 Mar 2026 22:24:24 +0000 (22:24 +0000)]
libstdc++: Micro-optimization for std::generator helper concept
The default_initializable concept is defined in terms of some builtins
which should be cheap to evaluate. Check that before instantiating the
allocator_traits class template.
libstdc++-v3/ChangeLog:
* include/std/generator (_Stateless_alloc): Swap order of
constraints.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Arsen Arsenović <arsen@aarsen.me>
Jakub Jelinek [Fri, 20 Mar 2026 08:11:28 +0000 (09:11 +0100)]
i386: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]
module;
#include <cstdarg>
export module pr124565;
export namespace std {
using std::va_list;
}
fails on alpha-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage
It doesn't fail on x86_64-linux because there va_list is __va_list_tag[]
(i.e. array type), while on alpha-linux it is __va_list_tag itself; and the
module code calls decl_linkage on it and returns lk_internal for C++11 and
later.
Now, decl_linkage on x86_64-linux on __va_list_tag directly also returns
incorrectly lk_internal, and as I have no way to test alpha, I've
bootstrapped/regtested on x86_64-linux and i686-linux the following patch.
IMHO it is still desirable even there even when it is just a latent issue.
2026-03-20 Jakub Jelinek <jakub@redhat.com>
PR target/124565
* config/i386/i386.cc (ix86_build_builtin_va_list_64): Set TREE_PUBLIC
on type_decl.
Jakub Jelinek [Fri, 20 Mar 2026 08:10:25 +0000 (09:10 +0100)]
sh: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124566]
Same problem as in PR124565 on alpha,
module;
#include <cstdarg>
export module pr124565;
export namespace std {
using std::va_list;
}
fails on sh4-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage
Same fix, tested again with a cross on that testcase.
E.g. the just posted g++.dg/plugin/std-module-exports* tests would
FAIL because of this on sh4-linux.
2026-03-20 Jakub Jelinek <jakub@redhat.com>
PR target/124566
* config/sh/sh.cc (sh_build_builtin_va_list): Set TREE_PUBLIC
on type_decl.
Richard Biener [Fri, 20 Mar 2026 07:30:06 +0000 (08:30 +0100)]
tree-optimization/124578 - fix copy&pasto
The following fixes a check on vro1->opcode to properly check
vro2->opcode. This is actually a harmless copy&paste issue since
a previous check guarnateed equality of both. Still it's less
confusing when fixed.
PR tree-optimization/124578
* tree-ssa-sccvn.cc (vn_reference_eq): Consistently check
fields from vro2.
Yangyu Chen [Mon, 23 Feb 2026 10:27:25 +0000 (18:27 +0800)]
fmv: Check DECL_VIRTUAL_P for virtual functions for LTO handling
When building with LTO, DECL_VINDEX is not always set for virtual
functions, which allows virtual functions to be incorrectly treated as
non-virtual and then being multi-versioned, and causes errors sometimes.
This patch addresses the issue by ensuring that we check DECL_VIRTUAL_P
instead of DECL_VINDEX when handling virtual functions during
multiversioning.
François Dumont [Mon, 16 Mar 2026 18:37:50 +0000 (19:37 +0100)]
libstdc++: [_GLIBCXX_DEBUG] Minor optimization on safe iterator detach
An iterator cannot be at the same time const and mutable so it cannot be
at the same time in both list of iterators maintained at debug container
level.
libstdc++-v3/ChangeLog:
* src/c++11/debug.cc (_Safe_sequence_base::_M_detach_single): Do not
check if input iterator is equal to _M_iterators if already equals to
_M_const_iterators.
(_Safe_unordered_container_base::_M_detach_local_single): Do not check
if input local iterator is equal to _M_local_iterators if already equals
to _M_const_local_iterators.
Jakub Jelinek [Thu, 19 Mar 2026 16:37:39 +0000 (17:37 +0100)]
libstdc++: Export std::enable_nonlocking_formatter_optimization in std.cc [PR121790]
On Thu, Mar 19, 2026 at 03:03:38PM +0000, Jonathan Wakely wrote:
> > enable_nonlocking_formatter_optimization has been added in PR121790 P3235R3
> > r16-4351, though bits/formatfwd.h hunk already in
> > PR121790 P3107R5 r16-4350. I wonder why it shows up for C++23 though.
>
> P3235R3 was approved as a DR for C++23, at the 2024-06 meeting:
> "8. Accept as a Defect Report and apply the changes in P3235R3
> (std::print more types faster with less memory) to the C++ working
> paper. "
> The committee kept approving a LOT of std::format and std::print changes as DRs.
> So it's enabled in the header for C++23, and so it should also be
> exported from the module for C++23.
Ok, in that case here is another patch to export it.
Jakub Jelinek [Thu, 19 Mar 2026 14:49:51 +0000 (15:49 +0100)]
alpha: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]
module;
#include <cstdarg>
export module pr124565;
export namespace std {
using std::va_list;
}
fails on alpha-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage
It doesn't fail on x86_64-linux because there va_list is __va_list_tag[]
(i.e. array type), while on alpha-linux it is __va_list_tag itself; and the
module code calls decl_linkage on it and returns lk_internal for C++11 and
later.
As I have no way to test this on alpha, I've just bootstrapped/regtested
similar change (just posted) on x86_64-linux and verified on the above
testcase that it fixes the problem in a cross to alpha-linux.
Not adding a testcase as any test which tries to compile bits/std.cc should
already catch it.
2026-03-19 Jakub Jelinek <jakub@redhat.com>
PR target/124565
* config/alpha/alpha.cc (alpha_build_builtin_va_list): Set TREE_PUBLIC
on type_decl.
Jonathan Wakely [Thu, 19 Mar 2026 11:42:48 +0000 (11:42 +0000)]
libstdc++: Fix parsing of UNTIL times in tzdata.zi [PR124513]
Zone lines ending with a plain number as the time for the DST transition
(e.g. "2026 Mar 16 2") were incorrectly parsed as changing at midnight.
The problem was that eofbit got set after extracting the "2" from the
stream using `in >> i`, then the `in >> at.indicator` expression
failed and set failbit, so that the `if (in >> at.indicator)` condition
was always false and so the assignment to at.time guarded by that
condition was never performed. So the at.time member was always left
equal to zero, i.e. midnight. Suffixed times such as "2s" or "2u" were
parsed correctly.
This commit fixes the operator>> overload for the Indicator enum to not
cause failbit to be set if eofbit is already set. This means that the
`in >> at.indicator` expression yields true when converted to bool, and
the assignment to at.time happens. Not trying to extract an Indicator
when eofbit is already set is correct, because it's valid for there to
be no indicator suffix on an AT time (that just means the time should be
interpreted as wall time).
There was also a bug in the handling of a "-" value for the time, which
is supposed to mean midnight but was not being parsed due to failing to
skip leading whitespace. That did no harm in most cases, because the "-"
would not be extracted from the stream but would then cause a failure to
parse an integer number of hours, and no time would be set, causing it
to default to midnight, which is what "-" means anyway. However, a value
of "-u" is supposed to mean midnight UTC and "-s" is supposed to mean
midnight standard time, and the indicators for UTC or standard were not
being set in those cases. This fix uses std::ws to skip initial
whitespace, and then correctly handles "-" followed by EOF.
libstdc++-v3/ChangeLog:
PR libstdc++/124513
* src/c++20/tzdb.cc (operator>>(istream&, at_time::Indicator&)):
Do not peek at the next character if eofbit is already set.
(istream& operator>>(istream&, at_time&)): Skip whitespace
before the first character. Handle EOF when parsing "-" as time.
Do not peek for ":" or "." if eofbit already set.
* testsuite/std/time/time_zone/116110.cc (test_apia): Remove
offset of 24h now that the UNTIL time is parsed correctly.
* testsuite/std/time/time_zone/124513.cc: New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Mon, 16 Mar 2026 21:48:30 +0000 (21:48 +0000)]
libstdc++: Partial fix for interpretation of non-UTC UNTIL times in tzdata.zi [PR116110]
This is a partial fix for PR 116110, so that zone changes that occur at
a time specified as standard time will be parsed correctly. Previously
all UNTIL times were assumed to be UTC, which is incorrect according to
the spec. Only times with a 'u' suffix (or the equivalent 'g' or 'z')
are UTC times. An 's' suffix means standard time (i.e. the zone's usual
offset from UTC, without any DST adjustment) and a 'w' suffix (or no
suffix) means wall time, so the offset and any DST adjustment. This
commit fixes the handling of 's' suffixes, so that the ZoneInfo::m_until
member is set correctly. It also fixes the handling of some UNTIL times
using wall time, specifically those where the DST adjustment is known
during parsing of the tzdata.zi file.
This is not a complete fix, because as noted in PR 116110 a Zone line
that refers to a named Rule and uses wall time cannot be determined
while parsing tzdata.zi. We need to remember that the m_until member is
not correct, and then adjust it later when we find the rule that applies
at a given time point. That requires more work.
Some existing tests need to be adjusted due to the fixes in this commit.
The std/time/time_zone/get_info_sys.cc and std/time/zoned_time/1.cc
tests are corrected to check that the changes happens at midnight local
time, not midnight UTC as previously assumed.
One of the FIXME comments in std/time/time_zone/116110.cc can be removed
now, because the UNTIL time is correctly interpreted as midnight local
time. The other FIXME needs to be changed to midnight at the local
standard time, which is still wrong but we don't currently adjust it for
the DST save time of one hour. It also still needs the incorrect +24h
due to Bug 124513.
libstdc++-v3/ChangeLog:
PR libstdc++/116110
* src/c++20/tzdb.cc (operator>>(istream&, ZoneInfo&)): Adjust
inf.m_until according to indicator suffix on AT time in UNTIL.
* testsuite/std/time/time_zone/116110.cc (test_kiritimati):
Remove FIXME now that the UNTIL time is adjusted for STDOFF.
(test_apia): Adjust FIXME now that UNTIL time is adusted for
STDOFF.
* testsuite/std/time/time_zone/get_info_sys.cc: Adjust expected
results to account for corrected logic.
* testsuite/std/time/zoned_time/1.cc: Likewise.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Sat, 14 Mar 2026 10:32:11 +0000 (10:32 +0000)]
libstdc++: Fix time zone transitions for Rule changes during DST [PR116110]
The Australia/Broken_Hill example in PR libstdc++/116110 demonstrates a
bug in the time zone code. The current code gives incorrect results when
a zone changes from one named Rule to another during DST, e.g. the
Broken_Hill time zone uses:
9:30 AN AC%sT 2000
9:30 AS AC%sT
So the AS Rules take effect on 2000 Jan 1 which is during DST (which
runs from October to March).
The fix for this is to update info.offset and info.save when we find an
active rule, instead of only updating the 'letters' variable.
The new tests for Pacific/Kiritimati and Pacific/Apia have some FIXME
comments. The UNTIL times of the zone changes are incorrectly
interpreted as UTC not wall time (due to the main topic of Bug 116110),
and the "24" time for the Pacific/Apia zone is incorrectly ignored so
that the change happens 24h too early (due to Bug 124554). Those tests
will need to be adjusted later when the bugs are fixed.
libstdc++-v3/ChangeLog:
PR libstdc++/116110
* src/c++20/tzdb.cc (time_zone::_M_get_sys_info): Update
info.offset and info.save to values from the active rule.
* testsuite/std/time/time_zone/116110.cc: New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>