SATURDAY, NOVEMBER 21, 2026
c++
C++29 gains support for new octal literal syntax.
GCC implements the first part of C++29 octal literal syntax, allowing '0o' and '0O' prefixes.
GCC now supports the ‘0o’ and ‘0O’ prefixes for octal literals, as proposed in C++29 paper P0085R5. This change allows for more explicit octal number representation in C++ code. Deprecation of older octal literal styles will be addressed in a subsequent patch.
In Details
This commit introduces support for the C++29 octal literal syntax (e.g., 0o42) by modifying libcpp's cpp_classify_number and lang_defaults. It also predefines __cpp_0o_octals and adds test cases. The change is minimal due to existing C octal parsing infrastructure. A future patch will handle deprecation of the traditional 042 syntax in C++.
For Context
- C++29
- The upcoming standard version of the C++ programming language, expected to be ratified in 2029. It introduces new features and language improvements.
- octal literal
- A number literal representing a value in base-8. Traditionally in C and C++, these are prefixed with a single '0' (e.g.,
042), which can sometimes be confused with decimal numbers. - P0085R5
- A C++ proposals document (revision 5) advocating for clearer syntax for octal literals, specifically introducing
0oand0Oprefixes. - libcpp
- The C++ standard library implementation used by Clang/LLVM. In GCC, the C preprocessor (cpplib) handles preprocessing for both C and C++.
- preprocessor
- A program that processes source code before the compiler proper. It handles directives like includes, macro expansions, and conditional compilation.