Hi! On Fri, Nov 20, 2026 at 08:09:41AM -0500, Jason Merrill wrote: > How many people do you think are already using -std=c++29? I think it's > useful to add the warning in 29 mode only. > > > I think we can add the > > deprecation as one of the last steps of C2Y or C++29 implementation in a > > year or three. Sure, for C++ adding the deprecation is easier because > > there is a FTM, but still unsure if people want to do > > #if __cpp_0o_octals >= 202611L > > 0o1234 > > #else > > 01234 > > #endif > > or > > #if __cpp_0o_octals >= 202611L > > #define OCTAL(o) 0o##o > > #else > > #define OCTAL(o) 0##o > > #endif > > OCTAL(1234) > > all around their code immediately, but sure, at some point they will have > > to. > > I suspect there's too much existing code to ever actually remove the old > form.
Ok, based on this I've written the following incremental patch on top of https://gcc.gnu.org/pipermail/gcc-patches/2026-November/740000.html which adds a new warning. Separate because it is not just for C++, but also for C. Right now it is enabled by default for C++29 and not for C2Y, but the defaults can be certainly changed, whether to postpone making it the default for C++29 for now, or also enable it by default for C2Y. The patch also shows (quite randomly) on the testsuite as well on 3 libstdc++ affected headers what users can do to deal with this (everything is admittedly ugly). The options are conditionalize code on the #if __cpp_0o_octals >= 202611L and duplicate small parts of code, similarly but use something like the OCTAL macro above (not actually used in the patch at all), rewrite 00 as 0, rewrite non-zero octal literals as decimal/hexadecimal instead (and possibly make errors in that), use pargmas to temporarily disable the warning around some code, use command line option to disable it (or enable it if say coding style rules somewhere require that) or just live with the warnings. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2026-11-21 Jakub Jelinek <[email protected]> gcc/ * doc/invoke.texi (Wdeprecated-octal-literal): Document. gcc/c-family/ * c.opt (Wdeprecated-octal-literal): New warning. * c.opt.urls: Regenerate. * c-opts.cc (c_common_post_options): Enable -Wdeprecated-octal-literal by default for C++29. gcc/testsuite/ * c-c++-common/Wdeprecated-octal-literal-1.c: New test. * c-c++-common/Wdeprecated-octal-literal-2.c: New test. * c-c++-common/Wdeprecated-octal-literal-3.c: New test. * c-c++-common/Wdeprecated-octal-literal-4.c: New test. * c-c++-common/Wdeprecated-octal-literal-5.c: New test. * c-c++-common/Wdeprecated-octal-literal-6.c: New test. * c-c++-common/Wprio-ctor-dtor.c: Expect extra warning for C++29. * c-c++-common/gomp/doacross-6.c: Likewise. * c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c: Use 0 instead of 00. * c-c++-common/analyzer/stdarg-pr111289-int.c: Expect extra warning for C++29. * g++.dg/ubsan/pr80349.C: Add -Wno-deprecated-octal-literal to dg-options. * g++.dg/ext/va-arg-pack-len-1.C: Likewise. * g++.dg/ext/va-arg-pack-len-2.C: Likewise. * g++.dg/cpp1y/digit-sep.C: Add -Wno-deprecated-octal-literal as dg-additional-options for C++29. * g++.dg/cpp1y/digit-sep-neg.C: Expect extra warnings for C++29. * g++.dg/warn/pr13358-4.C: Likewise. * g++.dg/warn/pr13358-3.C: Likewise. * g++.dg/cpp0x/udlit-raw-op.C: Likewise. * g++.dg/cpp0x/udlit-raw-length.C: Likewise. * g++.dg/vect/pr98064.cc: Add -Wno-deprecated-octal-literal to dg-additional-options. * g++.dg/vect/pr95297.cc: Likewise. * g++.old-deja/g++.niklas/t119.C: Expect extra warning for C++29. * g++.old-deja/g++.law/enum2.C: Add -Wno-deprecated-octal-literal to dg-options. * g++.old-deja/g++.other/mutable1.C: Add -Wno-deprecated-octal-literal as dg-additional-options for C++29. * g++.old-deja/g++.mike/p811.C: Add -Wno-deprecated-octal-literal to dg-options. libcpp/ * include/cpplib.h (struct cpp_options): Add cpp_warn_deprecated_octal_literal member. (enum cpp_warning_reason): Add CPP_W_DEPRECATED_OCTAL_LITERAL. * expr.cc (cpp_classify_number): Emit -Wdeprecated-octal-literal. libstdc++-v3/ * include/std/charconv (std::__detail::__to_chars_8): Use conditionally 0o prefixed literals instead of 0 prefixed ones or rewrite into decimal. * include/bits/fs_fwd.h (std::filesystem::perms): Temporarily ignore -Wdeprecated-octal-literal warning. * include/experimental/bits/fs_fwd.h (std::experimental::filesystem::perms): Likewise. * testsuite/std/time/format/pr120114.cc: Expect extra warning for C++29. * testsuite/20_util/to_chars/constexpr.cc (test_base8): Use conditionally 0o prefixed literals instead of 0 prefixed ones. * testsuite/23_containers/mdspan/layouts/stride_neg.cc: Replace 00 with 0. --- a/gcc/c-family/c.opt 2026-10-09 10:03:50.483185308 +0200 +++ b/gcc/c-family/c.opt 2026-11-20 19:16:31.772993998 +0100 @@ -695,6 +695,10 @@ Wdeprecated-non-prototype C ObjC Var(warn_deprecated_non_prototype) Init(-1) Warning Warn about calls with arguments to functions declared without parameters. +Wdeprecated-octal-literal +C ObjC C++ ObjC++ Warning Var(warn_deprecated_octal_literal) CPP(cpp_warn_deprecated_octal_literal) CppReason(CPP_W_DEPRECATED_OCTAL_LITERAL) Init(0) +Warn on octal literals with 0 prefix rather than 0o or 0O. + Wdeprecated-openmp C ObjC C++ ObjC++ Warning Var(warn_deprecated_openmp) Init(1) Warn about deprecated OpenMP code. --- a/gcc/c-family/c.opt.urls 2026-10-09 10:03:50.484185294 +0200 +++ b/gcc/c-family/c.opt.urls 2026-11-21 09:45:45.131173619 +0100 @@ -487,6 +487,9 @@ UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-literal-operato Wdeprecated-non-prototype UrlSuffix(gcc/Warning-Options.html#index-Wdeprecated-non-prototype) +Wdeprecated-octal-literal +UrlSuffix(gcc/Warning-Options.html#index-Wdeprecated-octal-literal) + Wdeprecated-openmp UrlSuffix(gcc/Warning-Options.html#index-Wdeprecated-openmp) LangUrlSuffix_Fortran(gfortran/Error-and-Warning-Options.html#index-Wdeprecated-openmp) --- a/gcc/c-family/c-opts.cc 2026-11-13 14:51:48.125023799 +0100 +++ b/gcc/c-family/c-opts.cc 2026-11-20 19:50:50.297920599 +0100 @@ -994,6 +994,16 @@ c_common_post_options (const char **pfil cpp_opts->cpp_warn_keyword_macro = warn_keyword_macro; } + /* For C++29 default to -Wdeprecated-octal-literal. */ + if (cxx_dialect >= cxx29) + { + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + warn_deprecated_octal_literal, 1); + if (warn_deprecated_octal_literal) + cpp_opts->cpp_warn_deprecated_octal_literal + = warn_deprecated_octal_literal; + } + /* -Wpacked-bitfield-compat is on by default for the C languages. The warning is issued in stor-layout.cc which is not part of the front-end so we need to selectively turn it on here. */ --- a/gcc/doc/invoke.texi 2026-11-19 09:25:45.423242670 +0100 +++ b/gcc/doc/invoke.texi 2026-11-20 20:12:10.779059510 +0100 @@ -392,7 +392,7 @@ Objective-C and Objective-C++ Dialects}. -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} -Wdate-time -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init --Wno-deprecated-openmp +-Wdeprecated-octal-literal -Wno-deprecated-openmp -Wdisabled-optimization -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers -Wno-div-by-zero -Wdouble-promotion @@ -11615,6 +11615,16 @@ Suppress warnings when a positional init a structure that has been marked with the @code{designated_init} attribute. +@opindex Wdeprecated-octal-literal +@opindex Wno-deprecated-octal-literal +@item -Wdeprecated-octal-literal +Warn on 0 prefixed octal literals other than 0. In C++29 and C2Y +octal literals should be specified with 0o or 0O prefix and the older +0 prefixed octal literals are deprecated. 0 is not deprecated, but +00 or 0177 is and should be written in C++29 or C2Y as 0o0 (or in this +case 0) or 0o177 (or 0O177). +This flag is enabled by default for @option{-std=c++29}. + @opindex Wzero-init-padding-bits= @item -Wzero-init-padding-bits=@var{value} Warn about automatic variable initializers that might not zero --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-1.c 2026-11-20 19:57:59.873266998 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-1.c 2026-11-20 19:57:34.210604742 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wdeprecated-octal-literal" } */ +/* { dg-additional-options "-std=c23" { target c } } */ + +int a = 0; +int b = 00; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +unsigned long long d = 042ULL; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#if 0U == 0 +#endif +#if 00l == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#endif +#if 042 == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#endif --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-2.c 2026-11-20 19:58:10.612125666 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-2.c 2026-11-20 19:58:33.632822691 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-deprecated-octal-literal" } */ +/* { dg-additional-options "-std=c23" { target c } } */ + +int a = 0; +int b = 00; +unsigned long long d = 042ULL; +#if 0U == 0 +#endif +#if 00l == 0 +#endif +#if 042 == 0 +#endif --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-3.c 2026-11-20 19:58:49.972607645 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-3.c 2026-11-20 20:03:51.629636463 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-additional-options "-std=c2y" { target c } } */ + +int a = 0; +int b = 00; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +unsigned long long d = 042ULL; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#if 0U == 0 +#endif +#if 00l == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#endif +#if 042 == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#endif --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-4.c 2026-11-20 19:59:52.043790734 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-4.c 2026-11-20 20:04:00.173523888 +0100 @@ -0,0 +1,10 @@ +/* { dg-do compile { target { c || c++14 } } } */ +/* { dg-options "-Wdeprecated-octal-literal" } */ +/* { dg-additional-options "-std=c23" { target c } } */ + +int a = 0'0; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +unsigned long b = 000'000'001UL; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#if 0'0U == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#endif +#if 01'23'45'67ul == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" } */ +#endif --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-5.c 2026-11-20 20:01:45.935291822 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-5.c 2026-11-20 20:04:29.430138393 +0100 @@ -0,0 +1,10 @@ +/* { dg-do compile { target { c || c++14 } } } */ +/* { dg-options "-Wno-deprecated-octal-literal" } */ +/* { dg-additional-options "-std=c23" { target c } } */ + +int a = 0'0; +unsigned long b = 000'000'001UL; +#if 0'0U == 0 +#endif +#if 01'23'45'67ul == 0 +#endif --- a/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-6.c 2026-11-20 20:02:18.550862572 +0100 +++ b/gcc/testsuite/c-c++-common/Wdeprecated-octal-literal-6.c 2026-11-20 20:04:46.610912014 +0100 @@ -0,0 +1,10 @@ +/* { dg-do compile { target { c || c++14 } } } */ +/* { dg-options "" } */ +/* { dg-additional-options "-std=c2y" { target c } } */ + +int a = 0'0; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +unsigned long b = 000'000'001UL; /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#if 0'0U == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#endif +#if 01'23'45'67ul == 0 /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated in" "" { target c++29 } } */ +#endif --- a/gcc/testsuite/c-c++-common/Wprio-ctor-dtor.c 2020-01-14 20:02:46.641611961 +0100 +++ b/gcc/testsuite/c-c++-common/Wprio-ctor-dtor.c 2026-11-21 09:02:58.151721172 +0100 @@ -6,5 +6,5 @@ void construct1 () __attribute__ ((const void construct2 () __attribute__ ((constructor (100))); void construct2 () __attribute__ ((constructor (101))); void destruct1 () __attribute__ ((destructor (1))); -void destruct2 () __attribute__ ((destructor (02))); +void destruct2 () __attribute__ ((destructor (02))); /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } */ void destruct2 () __attribute__ ((destructor (102))); --- a/gcc/testsuite/c-c++-common/gomp/doacross-6.c 2022-09-06 22:55:12.736363047 +0200 +++ b/gcc/testsuite/c-c++-common/gomp/doacross-6.c 2026-11-21 09:10:47.618312065 +0100 @@ -96,7 +96,7 @@ corge (int n) #pragma omp for ordered for (i = 0; i < 8; i += n) { - #pragma omp ordered doacross(sink:omp_cur_iteration - 001) + #pragma omp ordered doacross(sink:omp_cur_iteration - 001) // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } } #pragma omp for ordered for (i = 0; i < 8; i += n) --- a/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c 2025-04-30 18:19:09.955046652 +0200 +++ b/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c 2026-11-21 09:01:47.404679582 +0100 @@ -69,7 +69,7 @@ int load_revindex_from_disk(char *revind size_t revindex_size; struct revindex_header *hdr; - fd = git_open_cloexec(revindex_name, 00); + fd = git_open_cloexec(revindex_name, 0); if (fd < 0) { ret = -1; --- a/gcc/testsuite/c-c++-common/analyzer/stdarg-pr111289-int.c 2026-08-25 22:56:29.358839971 +0200 +++ b/gcc/testsuite/c-c++-common/analyzer/stdarg-pr111289-int.c 2026-11-21 09:00:49.946457975 +0100 @@ -22,7 +22,7 @@ test_1 (char const *name, ...) void call_test_1 () { - test_1 ("nonexist.ent/", 0600); + test_1 ("nonexist.ent/", 0600); /* { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } */ } /* Not the same size: small enough for int promotion. */ --- a/gcc/testsuite/g++.dg/ubsan/pr80349.C 2020-01-14 20:02:46.989606748 +0100 +++ b/gcc/testsuite/g++.dg/ubsan/pr80349.C 2026-11-21 09:11:40.921570771 +0100 @@ -1,6 +1,6 @@ // PR sanitizer/80349 // { dg-do compile } -// { dg-options "-fsanitize=undefined" } +// { dg-options "-fsanitize=undefined -Wno-deprecated-octal-literal" } extern const long long int v; --- a/gcc/testsuite/g++.dg/ext/va-arg-pack-len-1.C 2020-01-14 20:02:46.842608950 +0100 +++ b/gcc/testsuite/g++.dg/ext/va-arg-pack-len-1.C 2026-11-21 09:09:27.554425521 +0100 @@ -1,5 +1,5 @@ // { dg-do run } -// { dg-options "-O2" } +// { dg-options "-O2 -Wno-deprecated-octal-literal" } #include <stdarg.h> --- a/gcc/testsuite/g++.dg/ext/va-arg-pack-len-2.C 2020-01-14 20:02:46.842608950 +0100 +++ b/gcc/testsuite/g++.dg/ext/va-arg-pack-len-2.C 2026-11-21 09:09:44.342192051 +0100 @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-O2" } +// { dg-options "-O2 -Wno-deprecated-octal-literal" } #include <stdarg.h> --- a/gcc/testsuite/g++.dg/cpp1y/digit-sep.C 2020-01-14 20:02:46.774609969 +0100 +++ b/gcc/testsuite/g++.dg/cpp1y/digit-sep.C 2026-11-21 09:05:40.878516702 +0100 @@ -1,4 +1,5 @@ // { dg-do compile { target c++14 } } +// { dg-additional-options "-Wno-deprecated-octal-literal" { target c++29 } } #define assert(E) if(!(E))__builtin_abort(); --- a/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C 2021-05-10 22:57:46.347512002 +0200 +++ b/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C 2026-11-21 09:04:58.026097225 +0100 @@ -31,3 +31,4 @@ main() // { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 15 } // { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 19 } // { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 26 } +// { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } 12 } --- a/gcc/testsuite/g++.dg/warn/pr13358-4.C 2020-01-14 20:02:47.007606478 +0100 +++ b/gcc/testsuite/g++.dg/warn/pr13358-4.C 2026-11-21 09:07:33.432004292 +0100 @@ -12,7 +12,7 @@ void use_longlong () x1 = 0x1b27da572ef3cd86; // { dg-warning "integer constant is too large for 'long' type" "long long" { target { llp64 || ilp32 } } } x2 = 1956772631100509574; // { dg-warning "integer constant is too large for 'long' type" "long long" { target { llp64 || ilp32 } } } x3 = 0154476645345674746606; // { dg-warning "integer constant is too large for 'long' type" "long long" { target { llp64 || ilp32 } } } -} +} // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } .-1 } void use_longlong2 () { @@ -21,4 +21,4 @@ void use_longlong2 () x1 = 0x1b27da572ef3cd86LL; // { dg-warning "long long" } x2 = 1956772631100509574LL; // { dg-warning "long long" } x3 = 0154476645345674746606LL; // { dg-warning "long long" } -} +} // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } .-1 } --- a/gcc/testsuite/g++.dg/warn/pr13358-3.C 2020-01-14 20:02:47.007606478 +0100 +++ b/gcc/testsuite/g++.dg/warn/pr13358-3.C 2026-11-21 09:06:56.792493987 +0100 @@ -11,7 +11,7 @@ void use_longlong () // make sure it's ok with hex, decimal and octal x1 = 0x1b27da572ef3cd86; x2 = 1956772631100509574; - x3 = 0154476645345674746606; + x3 = 0154476645345674746606; // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } } void use_longlong2 () @@ -20,5 +20,5 @@ void use_longlong2 () // make sure it's ok with hex, decimal and octal x1 = 0x1b27da572ef3cd86LL; x2 = 1956772631100509574LL; - x3 = 0154476645345674746606LL; + x3 = 0154476645345674746606LL; // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } } --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C 2024-10-03 20:10:07.391515291 +0200 +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C 2026-11-21 09:08:39.103099336 +0100 @@ -13,7 +13,7 @@ operator ""_raw_umber(const char * str) int main() { - int i = 0123012301230123012301230123012301230123012301230123012301230123_raw_umber; + int i = 0123012301230123012301230123012301230123012301230123012301230123_raw_umber; // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } assert( i == 64 ); int j = 90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789_raw_umber; --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C 2024-10-03 20:10:07.391515291 +0200 +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C 2026-11-21 09:08:16.273416831 +0100 @@ -23,5 +23,5 @@ operator ""_lenraw(const char* digits) static_assert(123_lenraw == 3, "Ouch"); static_assert(1_lenraw == 1, "Ouch"); -static_assert(012_lenraw == 3, "Ouch"); +static_assert(012_lenraw == 3, "Ouch"); // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } static_assert(0_lenraw == 1, "Ouch"); --- a/gcc/testsuite/g++.dg/vect/pr98064.cc 2020-11-30 23:51:39.096165189 +0100 +++ b/gcc/testsuite/g++.dg/vect/pr98064.cc 2026-11-21 09:12:25.751947312 +0100 @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-additional-options "-O3" } +// { dg-additional-options "-O3 -Wno-deprecated-octal-literal" } const long long &min(const long long &__a, long long &__b) { if (__b < __a) --- a/gcc/testsuite/g++.dg/vect/pr95297.cc 2020-05-25 23:10:34.860232869 +0200 +++ b/gcc/testsuite/g++.dg/vect/pr95297.cc 2026-11-21 09:12:48.034637425 +0100 @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-additional-options "-O3 -fvect-cost-model=dynamic" } +// { dg-additional-options "-O3 -fvect-cost-model=dynamic -Wno-deprecated-octal-literal" } extern bool var_10; extern int var_16; --- a/gcc/testsuite/g++.old-deja/g++.niklas/t119.C 2020-01-14 20:02:47.058605714 +0100 +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t119.C 2026-11-21 09:15:26.612512257 +0100 @@ -2,5 +2,5 @@ // GROUPS passed niklas i386 unsigned long foo(unsigned long x) { - return x & ~0104000; + return x & ~0104000; // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } } --- a/gcc/testsuite/g++.old-deja/g++.law/enum2.C 2020-01-14 20:02:47.044605924 +0100 +++ b/gcc/testsuite/g++.old-deja/g++.law/enum2.C 2026-11-21 09:13:46.034856758 +0100 @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options "-fshort-enums" } +// { dg-options "-fshort-enums -Wno-deprecated-octal-literal" } // GROUPS passed enums // enum file // From: Jeff Gehlhaar <[email protected]> --- a/gcc/testsuite/g++.old-deja/g++.other/mutable1.C 2020-01-14 20:02:47.070605535 +0100 +++ b/gcc/testsuite/g++.old-deja/g++.other/mutable1.C 2026-11-21 09:14:39.786138221 +0100 @@ -1,4 +1,5 @@ -// { dg-do run } +// { dg-do run } +// { dg-additional-options "-Wno-deprecated-octal-literal" { target c++29 } } // Copyright (C) 1999 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 14 Jan 1999 <[email protected]> --- a/gcc/testsuite/g++.old-deja/g++.mike/p811.C 2024-11-30 12:35:54.536717449 +0100 +++ b/gcc/testsuite/g++.old-deja/g++.mike/p811.C 2026-11-21 09:13:24.811140473 +0100 @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options "-Wno-builtin-declaration-mismatch" } +// { dg-options "-Wno-builtin-declaration-mismatch -Wno-deprecated-octal-literal" } // This test case caused the compiler to abort at one point in time. // prms-id: 811 --- a/libcpp/include/cpplib.h 2026-08-29 14:18:54.493770953 +0200 +++ b/libcpp/include/cpplib.h 2026-11-20 19:46:15.870532314 +0100 @@ -637,6 +637,9 @@ struct cpp_options /* -Wtrailing-whitespace= value. */ unsigned char cpp_warn_trailing_whitespace; + /* Nonzero means complain about deprecated octal literals. */ + unsigned char cpp_warn_deprecated_octal_literal; + /* -ftabstop= value. */ unsigned int cpp_tabstop; @@ -770,7 +773,8 @@ enum cpp_warning_reason { CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER, CPP_W_LEADING_WHITESPACE, CPP_W_TRAILING_WHITESPACE, - CPP_W_KEYWORD_MACRO + CPP_W_KEYWORD_MACRO, + CPP_W_DEPRECATED_OCTAL_LITERAL }; /* Callback for header lookup for HEADER, which is the name of a --- a/libcpp/expr.cc 2026-11-20 08:59:29.400202739 +0100 +++ b/libcpp/expr.cc 2026-11-20 19:46:29.358354801 +0100 @@ -920,6 +920,28 @@ cpp_classify_number (cpp_reader *pfile, } } + if (radix == 8 + && CPP_OPTION (pfile, cpp_warn_deprecated_octal_literal) + && !zero_o_prefix + && str > token->val.str.text + 1) + { + bool warned + = (CPP_OPTION (pfile, cplusplus) + ? cpp_warning_with_line (pfile, CPP_W_DEPRECATED_OCTAL_LITERAL, + virtual_location, 0, + "octal literals without %<0o%> or " + "%<0O%> prefix other than %<0%> are " + "deprecated in C++29") + : cpp_warning_with_line (pfile, CPP_W_DEPRECATED_OCTAL_LITERAL, + virtual_location, 0, + "octal literals without %<0o%> or " + "%<0O%> prefix other than %<0%> are " + "deprecated in C2Y")); + if (warned) + cpp_error_with_line (pfile, CPP_DL_NOTE, virtual_location, 0, + "use %<0o%> or %<0O%> prefix instead"); + } + result |= CPP_N_INTEGER; } --- a/libstdc++-v3/include/std/charconv 2026-11-16 22:14:25.148310626 +0100 +++ b/libstdc++-v3/include/std/charconv 2026-11-20 23:39:08.842349966 +0100 @@ -248,12 +248,21 @@ namespace __detail if constexpr (__gnu_cxx::__int_traits<_Tp>::__digits <= 16) { +#if __cpp_0o_octals >= 202611L + __len = __val > 0o77777u ? 6u + : __val > 0o7777u ? 5u + : __val > 0o777u ? 4u + : __val > 0o77u ? 3u + : __val > 0o7u ? 2u + : 1u; +#else __len = __val > 077777u ? 6u : __val > 07777u ? 5u : __val > 0777u ? 4u : __val > 077u ? 3u : __val > 07u ? 2u : 1u; +#endif } else __len = (__to_chars_len_2(__val) + 2) / 3; @@ -266,7 +275,7 @@ namespace __detail } unsigned __pos = __len - 1; - while (__val >= 0100) + while (__val >= 8 * 8) { auto __num = __val & 7; __val >>= 3; @@ -276,7 +285,7 @@ namespace __detail __first[__pos - 1] = '0' + __num; __pos -= 2; } - if (__val >= 010) + if (__val >= 8) { auto const __num = __val & 7; __val >>= 3; --- a/libstdc++-v3/include/bits/fs_fwd.h 2026-03-27 10:17:22.866188249 +0100 +++ b/libstdc++-v3/include/bits/fs_fwd.h 2026-11-20 23:42:32.257888513 +0100 @@ -141,6 +141,8 @@ _GLIBCXX_END_NAMESPACE_CXX11 /// Bitmask type representing file access permissions +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-octal-literal" enum class perms : unsigned { none = 0, owner_read = 0400, @@ -162,6 +164,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 mask = 07777, unknown = 0xFFFF, }; +#pragma GCC diagnostic pop /// @{ /// @relates perms --- a/libstdc++-v3/include/experimental/bits/fs_fwd.h 2026-01-02 22:41:17.645547488 +0100 +++ b/libstdc++-v3/include/experimental/bits/fs_fwd.h 2026-11-21 09:20:05.016794130 +0100 @@ -151,6 +151,8 @@ _GLIBCXX_END_NAMESPACE_CXX11 /// @} /// Bitmask type representing file access permissions +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-octal-literal" enum class perms : unsigned { none = 0, owner_read = 0400, @@ -175,6 +177,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 remove_perms = 0x20000, symlink_nofollow = 0x40000 }; +#pragma GCC diagnostic pop /// @{ /// @relates std::experimental::filesystem::perms --- a/libstdc++-v3/testsuite/std/time/format/pr120114.cc 2026-10-27 22:01:43.106329247 +0100 +++ b/libstdc++-v3/testsuite/std/time/format/pr120114.cc 2026-11-21 09:22:16.069044347 +0100 @@ -16,7 +16,7 @@ test_from_format_string() { std::basic_string<CharT> res; using namespace std::chrono_literals; - auto date = 2025y/std::chrono::May/05d; + auto date = 2025y/std::chrono::May/05d; // { dg-warning "octal literals without '0o' or '0O' prefix other than '0' are deprecated" "" { target c++29 } } res = std::format(WIDEN("{:+<13%F\U0001f921}"), date); VERIFY( res == WIDEN("2025-05-05\U0001f921+") ); --- a/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc 2023-11-16 23:00:45.691384018 +0100 +++ b/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc 2026-11-21 09:18:51.405776973 +0100 @@ -80,13 +80,25 @@ test_base8() { std::to_chars_result res; char buf[10] = "XXXXXXXXX"; +#if __cpp_0o_octals >= 202611L + res = std::to_chars(buf, buf+2, 0o1234, 8); +#else res = std::to_chars(buf, buf+2, 01234, 8); +#endif VERIFY( res.ptr == buf+2 ); VERIFY( res.ec == std::errc::value_too_large ); +#if __cpp_0o_octals >= 202611L + res = std::to_chars(buf, buf+3, -0o1234, 8); +#else res = std::to_chars(buf, buf+3, -01234, 8); +#endif VERIFY( res.ptr == buf+3 ); VERIFY( res.ec == std::errc::value_too_large ); +#if __cpp_0o_octals >= 202611L + res = std::to_chars(buf, buf+4, 0o1234, 8); +#else res = std::to_chars(buf, buf+4, 01234, 8); +#endif VERIFY( res.ptr == buf+4 ); VERIFY( res.ec == std::errc{} ); VERIFY( buf[0] == '1' ); @@ -94,7 +106,11 @@ test_base8() VERIFY( buf[2] == '3' ); VERIFY( buf[3] == '4' ); VERIFY( buf[4] == 'X' ); +#if __cpp_0o_octals >= 202611L + res = std::to_chars(buf, buf+10, -0o567, 8); +#else res = std::to_chars(buf, buf+10, -0567, 8); +#endif VERIFY( res.ptr == buf+4 ); VERIFY( res.ec == std::errc{} ); VERIFY( buf[0] == '-' ); --- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc 2026-10-05 21:24:44.000000000 +0200 +++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc 2026-11-21 09:21:10.746916512 +0100 @@ -71,16 +71,16 @@ constexpr auto m20 = mapping<4>(array{3, // Any stride values are allowed for extents 1 constexpr auto m21 = mapping<2>(array{1, 1}, array{88, 99}); // { dg-bogus "expansion of" } constexpr auto m2a = mapping<2>(array{5, 1}, array{88, 99}); // { dg-bogus "expansion of" } -constexpr auto m22 = mapping<3>(array{1, 1, 1}, array{88, 99, 00}); // { dg-bogus "expansion of" } +constexpr auto m22 = mapping<3>(array{1, 1, 1}, array{88, 99, 0}); // { dg-bogus "expansion of" } constexpr auto m2b = mapping<3>(array{1, 5, 1}, array{88, 99, 77}); // { dg-bogus "expansion of" } -constexpr auto m23 = mapping<4>(array{1, 1, 1, 1}, array{77, 99, 00, 88}); // { dg-bogus "expansion of" } +constexpr auto m23 = mapping<4>(array{1, 1, 1, 1}, array{77, 99, 0, 88}); // { dg-bogus "expansion of" } constexpr auto m2c = mapping<4>(array{1, 1, 5, 1}, array{77, 99, 1, 88}); // { dg-bogus "expansion of" } constexpr auto m24 = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 3, 3, 45}); // { dg-bogus "expansion of" } constexpr auto m25 = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 3, 10, 45}); // { dg-bogus "expansion of" } constexpr auto m26 = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 10, 3, 45}); // { dg-bogus "expansion of" } constexpr auto m27 = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 10, 10, 45}); // { dg-bogus "expansion of" } -constexpr auto m2d = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 00, 99, 45}); // { dg-bogus "expansion of" } -constexpr auto m2e = mapping<5>(array{1, 1, 1, 1, 1}, array{00, 77, 88, 99, 00}); // { dg-bogus "expansion of" } +constexpr auto m2d = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 0, 99, 45}); // { dg-bogus "expansion of" } +constexpr auto m2e = mapping<5>(array{1, 1, 1, 1, 1}, array{0, 77, 88, 99, 0}); // { dg-bogus "expansion of" } // { dg-prune-output "non-constant condition for static assertion" } // { dg-prune-output "__glibcxx_assert_fail()" } Jakub
