Open
Description
When building with libc project enabled, i get the following error:
./libc/src/__support/big_int.h:795:26: error: iteration 258 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
795 | remainder[pos - 1] = val[pos - 1];
| ~~~~~~~~~~~~~~~~~~~^~~~~~
./libc/src/__support/big_int.h:794:16: note: within this loop
794 | for (; pos > 0; --pos) {
| ~~~~^~~
This is the command:
/usr/bin/c++ -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/build/projects/libc/src/stdio/generic -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/generic -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc -isystem /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -fext-numeric-literals -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STDIO_USE_SYSTEM_FILE -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY=1 -DLIBC_COPT_PRINTF_RUNTIME_DISPATCH -std=c++17 -MD -MT projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o -MF projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o.d -o projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o -c /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/generic/vprintf.cpp
And this is the full error:
[862/12538] Building CXX object projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o
FAILED: projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o
/usr/bin/c++ -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/build/projects/libc/src/stdio/generic -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/generic -I/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc -isystem /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -fext-numeric-literals -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STDIO_USE_SYSTEM_FILE -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY=1 -DLIBC_COPT_PRINTF_RUNTIME_DISPATCH -std=c++17 -MD -MT projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o -MF projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o.d -o projects/libc/src/stdio/generic/CMakeFiles/libc.src.stdio.generic.vprintf.dir/vprintf.cpp.o -c /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/generic/vprintf.cpp
In file included from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/printf_main.h:16,
from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/vfprintf_internal.h:17,
from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/generic/vprintf.cpp:14:
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/parser.h: In instantiation of ‘__llvm_libc_21_0_0_git::cpp::optional<T> __llvm_libc_21_0_0_git::printf_core::Parser<ArgProvider>::get_arg_value(size_t) [with T = long double; ArgProvider = __llvm_libc_21_0_0_git::internal::ArgList; size_t = long unsigned int]’:
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/parser.h:242:11: required from ‘__llvm_libc_21_0_0_git::printf_core::FormatSection __llvm_libc_21_0_0_git::printf_core::Parser<ArgProvider>::get_next_section() [with ArgProvider = __llvm_libc_21_0_0_git::internal::ArgList]’
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/printf_main.h:29:59: required from ‘int __llvm_libc_21_0_0_git::printf_core::printf_main(Writer<write_mode>*, const char*, __llvm_libc_21_0_0_git::internal::ArgList&) [with WriteMode write_mode = __llvm_libc_21_0_0_git::printf_core::WriteMode::RUNTIME_DISPATCH]’
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/vfprintf_internal.h:79:27: required from here
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/parser.h:429:51: note: the ABI of passing union with ‘long double’ has changed in GCC 4.4
429 | template <class T> LIBC_INLINE cpp::optional<T> get_arg_value(size_t index) {
| ^~~~~~~~~~~~~
In file included from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/uint128.h:12,
from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/FPUtil/FPBits.h:27,
from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/core_structs.h:16,
from /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/stdio/printf_core/vfprintf_internal.h:16:
In member function ‘constexpr __llvm_libc_21_0_0_git::cpp::optional<__llvm_libc_21_0_0_git::BigInt<Bits, Signed, WordType> > __llvm_libc_21_0_0_git::BigInt<Bits, Signed, WordType>::div_uint_half_times_pow_2(__llvm_libc_21_0_0_git::multiword::half_width_t<WordType>, size_t) [with long unsigned int Bits = 16512; bool Signed = false; WordType = long unsigned int]’,
inlined from ‘static constexpr __llvm_libc_21_0_0_git::BlockInt __llvm_libc_21_0_0_git::FloatToString<long double>::grab_digits(__llvm_libc_21_0_0_git::UInt<Bits>&) [with long unsigned int Bits = 16512]’ at /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/float_to_string.h:653:57,
inlined from ‘constexpr void __llvm_libc_21_0_0_git::FloatToString<long double>::init_convert()’ at /home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/float_to_string.h:691:62:
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/big_int.h:795:26: error: iteration 258 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
795 | remainder[pos - 1] = val[pos - 1];
| ~~~~~~~~~~~~~~~~~~~^~~~~~
/home/null/Documents/R600/llvm-project-b233d79623dd3a6d307db2bc73ddd12e3a054460/libc/src/__support/big_int.h:794:16: note: within this loop
794 | for (; pos > 0; --pos) {
| ~~~~^~~
cc1plus: all warnings being treated as errors
This error is present for files vprintf.cpp.o, printf.cpp.o, vsprintf.cpp.o, vasprintf.cpp.o, snprintf.cpp.o, vfprintf.cpp.o, fprintf.cpp.o, and many more.