Skip to content

Conversation

@stbergmann
Copy link
Collaborator

@stbergmann stbergmann commented May 5, 2025

After 8fc2538 "Reapply '[libc++] Optimize num_put integral functions' (#131613) (#133572)",

#include <locale>

started to fail with

$ clang++ -stdlib=libc++ -std=c++03 -fsyntax-only test.cc
In file included from test.cc:1:
~/llvm/inst/bin/../include/c++/v1/locale:1280:41: error: no matching constructor for initialization of 'std::errc'
1280 | _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(), "to_chars: invalid maximum buffer size computed?");
| ^
~/llvm/inst/bin/../include/c++/v1/__assert:94:86: note: expanded from macro '_LIBCPP_ASSERT_INTERNAL'
94 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
| ^
~/llvm/inst/bin/../include/c++/v1/__assert:21:39: note: expanded from macro '_LIBCPP_ASSERT'
21 | (__builtin_expect(static_cast(expression), 1)
| ^
~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
~/llvm/inst/bin/../include/c++/v1/__config:618:29: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
618 | _LIBCPP_HIDE_FROM_ABI x(__lx __v) : _v(__v) {}
| ^ ~~~~~~~~
~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
~/llvm/inst/bin/../include/c++/v1/__config:619:38: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
619 | _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : _v(static_cast<__lx>(__v)) {}
| ^ ~~~~~~~
~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:143:29: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
143 | _LIBCPP_DECLARE_STRONG_ENUM(errc){
| ^~~~
1 error generated.

After 8fc2538 "Reapply '[libc++] Optimize
num_put integral functions' (#131613) (#133572)",

> $ cat test.cc
> #include <locale>

started to fail with

> $ clang++ -stdlib=libc++ -std=c++03 -fsyntax-only test.cc
> In file included from test.cc:1:
> ~/llvm/inst/bin/../include/c++/v1/locale:1280:41: error: no matching constructor for initialization of 'std::errc'
>  1280 |   _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(), "to_chars: invalid maximum buffer size computed?");
>       |                                         ^
> ~/llvm/inst/bin/../include/c++/v1/__assert:94:86: note: expanded from macro '_LIBCPP_ASSERT_INTERNAL'
>    94 | #  define _LIBCPP_ASSERT_INTERNAL(expression, message)                _LIBCPP_ASSERT(expression, message)
>       |                                                                                      ^
> ~/llvm/inst/bin/../include/c++/v1/__assert:21:39: note: expanded from macro '_LIBCPP_ASSERT'
>    21 |   (__builtin_expect(static_cast<bool>(expression), 1)                                                                  \
>       |                                       ^
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
>   262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
>       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> ~/llvm/inst/bin/../include/c++/v1/__config:618:29: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
>   618 |       _LIBCPP_HIDE_FROM_ABI x(__lx __v) : __v_(__v) {}                                                                 \
>       |                             ^ ~~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
>   262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
>       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> ~/llvm/inst/bin/../include/c++/v1/__config:619:38: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
>   619 |       _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : __v_(static_cast<__lx>(__v)) {}                                      \
>       |                                      ^ ~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:143:29: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
>   143 | _LIBCPP_DECLARE_STRONG_ENUM(errc){
>       |                             ^~~~
> 1 error generated.
@stbergmann stbergmann requested a review from a team as a code owner May 5, 2025 12:39
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 5, 2025
@llvmbot
Copy link
Member

llvmbot commented May 5, 2025

@llvm/pr-subscribers-libcxx

Author: Stephan Bergmann (stbergmann)

Changes

After 8fc2538 "Reapply '[libc++] Optimize num_put integral functions' (#131613) (#133572)",

> $ cat test.cc
> #include <locale>

started to fail with

> $ clang++ -stdlib=libc++ -std=c++03 -fsyntax-only test.cc
> In file included from test.cc:1:
> ~/llvm/inst/bin/../include/c++/v1/locale:1280:41: error: no matching constructor for initialization of 'std::errc'
> 1280 | _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(), "to_chars: invalid maximum buffer size computed?");
> | ^
> ~/llvm/inst/bin/../include/c++/v1/__assert:94:86: note: expanded from macro '_LIBCPP_ASSERT_INTERNAL'
> 94 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
> | ^
> ~/llvm/inst/bin/../include/c++/v1/__assert:21:39: note: expanded from macro '_LIBCPP_ASSERT'
> 21 | (__builtin_expect(static_cast<bool>(expression), 1)
> | ^
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
> 262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> ~/llvm/inst/bin/../include/c++/v1/__config:618:29: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
> 618 | _LIBCPP_HIDE_FROM_ABI x(__lx __v) : _v(__v) {}
> | ^ ~~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:262:36: note: candidate constructor not viable: requires single argument '__v', but no arguments were provided
> 262 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> ~/llvm/inst/bin/../include/c++/v1/__config:619:38: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
> 619 | _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : _v(static_cast<__lx>(__v)) {}
> | ^ ~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__system_error/errc.h:143:29: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
> 143 | _LIBCPP_DECLARE_STRONG_ENUM(errc){
> | ^~~~
> 1 error generated.


Full diff: https://github.com/llvm/llvm-project/pull/138522.diff

1 Files Affected:

  • (modified) libcxx/include/locale (+1-1)
diff --git a/libcxx/include/locale b/libcxx/include/locale
index fa2620d883598..b206bf8f162f9 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -1277,7 +1277,7 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_
   }
 
   auto __res = std::__to_chars_integral(__buffer_ptr, __char_buffer + __buffer_size, __uval, __base);
-  _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(), "to_chars: invalid maximum buffer size computed?");
+  _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(0), "to_chars: invalid maximum buffer size computed?");
 
   // Make letters uppercase
   if (__flags & ios_base::hex && __flags & ios_base::uppercase) {

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this fell through the cracks of our CI because this requires a combination of hardening mode = Debug and C++03. I don't think it makes sense to add that combination specifically, though -- while we should test all combinations in theory, in practice this is not feasible due to combinatorial explosion. So I think I'll take the patch as-is without increasing test coverage.

@ldionne ldionne merged commit b233c5f into llvm:main May 12, 2025
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants