diff --git a/regression-tests/mixed-type-safety-1.cpp2 b/regression-tests/mixed-type-safety-1.cpp2 index eb3331b42..d175d59e0 100644 --- a/regression-tests/mixed-type-safety-1.cpp2 +++ b/regression-tests/mixed-type-safety-1.cpp2 @@ -14,12 +14,14 @@ print: ( msg: std::string, x: T ) = main: () -> int = { - print( "1.1 is int?", 1.1 is int ); - print( "1 is int?", 1 is int ); + // Full qualification is necessary to avoid ambiguity in C++23 + // C++23 defines std::print, which would be picked up here by ADL + ::print( "1.1 is int?", 1.1 is int ); + ::print( "1 is int?", 1 is int ); c := new(); // safe by construction s : * Shape = c.get(); // safe by Lifetime - print("\ns* is Shape? ", s* is Shape ); - print( "s* is Circle?", s* is Circle ); - print( "s* is Square?", s* is Square ); + ::print("\ns* is Shape? ", s* is Shape ); + ::print( "s* is Circle?", s* is Circle ); + ::print( "s* is Square?", s* is Square ); } diff --git a/regression-tests/pure2-type-safety-1.cpp2 b/regression-tests/pure2-type-safety-1.cpp2 index 049c9075d..11734de99 100644 --- a/regression-tests/pure2-type-safety-1.cpp2 +++ b/regression-tests/pure2-type-safety-1.cpp2 @@ -23,7 +23,9 @@ main: () -> int = test_generic: ( x, msg ) = { msgx: std::string = msg; - print( msgx + " is int? ", x is int ); + // Full qualification is necessary to avoid ambiguity in C++23 + // C++23 defines std::print, which would be picked up here by ADL + ::print( msgx + " is int? ", x is int ); } print: ( msg: std::string, b: bool ) = { diff --git a/regression-tests/test-results/clang-18-c++23-libcpp/mixed-bugfix-for-ufcs-non-local.cpp.output.rej b/regression-tests/test-results/clang-18-c++23-libcpp/mixed-bugfix-for-ufcs-non-local.cpp.output.rej deleted file mode 100644 index 1dd32b2ba..000000000 --- a/regression-tests/test-results/clang-18-c++23-libcpp/mixed-bugfix-for-ufcs-non-local.cpp.output.rej +++ /dev/null @@ -1,64 +0,0 @@ ---- test-results/clang-18-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output -+++ test-results/clang-18-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output -@@ -1,41 +1,41 @@ - In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: --../../../include/cpp2util.h:1135:1: error: lambda-expression in template parameter type -- 1135 | [LAMBDADEFCAPT]< \ -+../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type -+ 1136 | [LAMBDADEFCAPT]< \ - | ^ --../../../include/cpp2util.h:1172:59: note: in expansion of macro ‘CPP2_UFCS_’ -- 1172 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -+../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ -+ 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - | ^~~~~~~~~~ - mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ - mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid --../../../include/cpp2util.h:1135:1: error: lambda-expression in template parameter type -- 1135 | [LAMBDADEFCAPT]< \ -+../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type -+ 1136 | [LAMBDADEFCAPT]< \ - | ^ --../../../include/cpp2util.h:1172:59: note: in expansion of macro ‘CPP2_UFCS_’ -- 1172 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -+../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ -+ 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - | ^~~~~~~~~~ - mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ - mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid --../../../include/cpp2util.h:1135:1: error: lambda-expression in template parameter type -- 1135 | [LAMBDADEFCAPT]< \ -+../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type -+ 1136 | [LAMBDADEFCAPT]< \ - | ^ --../../../include/cpp2util.h:1172:59: note: in expansion of macro ‘CPP2_UFCS_’ -- 1172 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -+../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ -+ 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - | ^~~~~~~~~~ - mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ - mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid --../../../include/cpp2util.h:1135:1: error: lambda-expression in template parameter type -- 1135 | [LAMBDADEFCAPT]< \ -+../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type -+ 1136 | [LAMBDADEFCAPT]< \ - | ^ --../../../include/cpp2util.h:1172:59: note: in expansion of macro ‘CPP2_UFCS_’ -- 1172 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -+../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ -+ 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - | ^~~~~~~~~~ - mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ - mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid --../../../include/cpp2util.h:1135:1: error: lambda-expression in template parameter type -- 1135 | [LAMBDADEFCAPT]< \ -+../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type -+ 1136 | [LAMBDADEFCAPT]< \ - | ^ --../../../include/cpp2util.h:1172:59: note: in expansion of macro ‘CPP2_UFCS_’ -- 1172 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -+../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ -+ 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - | ^~~~~~~~~~ - mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ - mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid diff --git a/regression-tests/test-results/clang-18-c++23-libcpp/mixed-type-safety-1.cpp.output b/regression-tests/test-results/clang-18-c++23-libcpp/mixed-type-safety-1.cpp.output deleted file mode 100644 index 53616ba57..000000000 --- a/regression-tests/test-results/clang-18-c++23-libcpp/mixed-type-safety-1.cpp.output +++ /dev/null @@ -1,239 +0,0 @@ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:202: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:98:30: error: call to deleted constructor of 'formatter, char>' - 98 | formatter<_Tp, _CharT> __f; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:97:62: note: while substituting into a lambda expression here - 97 | __parse_ = [](basic_format_parse_context<_CharT>& __ctx) { - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:392:25: note: in instantiation of function template specialization 'std::__format::__compile_time_handle::__enable>' requested here - 392 | __handle.template __enable<_Tp>(); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:388:99: note: while substituting into a lambda expression here - 388 | static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] { - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:372:54: note: in instantiation of static data member 'std::basic_format_string>::__handles_' requested here - 372 | _Context{__types_.data(), __handles_.data(), sizeof...(_Args)}); - | ^ -mixed-type-safety-1.cpp2:17:11: note: in instantiation of function template specialization 'std::basic_format_string>::basic_format_string' requested here - 17 | print("1.1 is int?", cpp2::impl::is(1.1)); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/formatter.h:36:3: note: 'formatter' has been explicitly marked deleted here - 36 | formatter() = delete; - | ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:202: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:99:28: error: no member named 'parse' in 'std::formatter>' - 99 | __ctx.advance_to(__f.parse(__ctx)); - | ~~~ ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:98:30: error: call to deleted constructor of 'formatter, char>' - 98 | formatter<_Tp, _CharT> __f; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:97:62: note: while substituting into a lambda expression here - 97 | __parse_ = [](basic_format_parse_context<_CharT>& __ctx) { - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:392:25: note: in instantiation of function template specialization 'std::__format::__compile_time_handle::__enable>' requested here - 392 | __handle.template __enable<_Tp>(); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:388:99: note: while substituting into a lambda expression here - 388 | static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] { - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:372:54: note: in instantiation of static data member 'std::basic_format_string>::__handles_' requested here - 372 | _Context{__types_.data(), __handles_.data(), sizeof...(_Args)}); - | ^ -mixed-type-safety-1.cpp2:18:12: note: in instantiation of function template specialization 'std::basic_format_string>::basic_format_string' requested here - 18 | print( "1 is int?", cpp2::impl::is(1)); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/formatter.h:36:3: note: 'formatter' has been explicitly marked deleted here - 36 | formatter() = delete; - | ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:202: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:99:28: error: no member named 'parse' in 'std::formatter>' - 99 | __ctx.advance_to(__f.parse(__ctx)); - | ~~~ ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:195: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/container_adaptor.h:20: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_default_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/format_context.h:18: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:167:17: error: static assertion failed due to requirement '__arg != __arg_t::__none': the supplied type is not formattable - 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); - | ^~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:214:54: note: in instantiation of function template specialization 'std::__format::__create_format_arg>' requested here - 214 | basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:249:19: note: in instantiation of function template specialization 'std::__format::__create_packed_storage>' requested here - 249 | __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:70:10: note: in instantiation of member function 'std::__format_arg_store>::__format_arg_store' requested here - 70 | return _VSTD::__format_arg_store<_Context, _Args...>(__args...); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__config:880:17: note: expanded from macro '_VSTD' - 880 | # define _VSTD std - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:331:59: note: in instantiation of function template specialization 'std::make_format_args>' requested here - 331 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:341:8: note: in instantiation of function template specialization 'std::print>' requested here - 341 | std::print(stdout, __fmt, std::forward<_Args>(__args)...); - | ^ -mixed-type-safety-1.cpp2:17:5: note: in instantiation of function template specialization 'std::print>' requested here - 17 | print("1.1 is int?", cpp2::impl::is(1.1)); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:167:23: note: expression evaluates to '0 != 0' - 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); - | ~~~~~~^~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:169:17: error: static assertion failed - 169 | static_assert(__formattable_with<_Tp, _Context>); - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:169:17: note: because '__formattable_with, std::format_context>' evaluated to false -/usr/lib/llvm-18/bin/../include/c++/v1/__format/concepts.h:49:5: note: because 'std::formatter>' does not satisfy 'semiregular' - 49 | semiregular<_Formatter> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/semiregular.h:27:23: note: because 'std::formatter>' does not satisfy 'copyable' - 27 | concept semiregular = copyable<_Tp> && default_initializable<_Tp>; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/copyable.h:30:5: note: because 'std::formatter>' does not satisfy 'copy_constructible' - 30 | copy_constructible<_Tp> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:45:5: note: because 'std::formatter>' does not satisfy 'move_constructible' - 45 | move_constructible<_Tp> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:39:30: note: because 'constructible_from >, std::formatter > >' evaluated to false - 39 | concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:27:51: note: because 'is_constructible_v >, std::formatter > >' evaluated to false - 27 | concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; - | ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:195: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/container_adaptor.h:20: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_default_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/format_context.h:18: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:205:12: error: no matching constructor for initialization of 'basic_format_arg' - 205 | return basic_format_arg<_Context>{__arg, __value}; - | ^ ~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:251:34: note: candidate constructor not viable: no known conversion from 'std::integral_constant' to '__basic_format_arg_value' for 2nd argument - 251 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type, - | ^ - 252 | __basic_format_arg_value<_Context> __value) noexcept - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided - 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { - | ^~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided - 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { - | ^~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:229:25: note: candidate constructor not viable: requires 0 arguments, but 2 were provided - 229 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {} - | ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:195: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/container_adaptor.h:20: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_default_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/format_context.h:18: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:167:17: error: static assertion failed due to requirement '__arg != __arg_t::__none': the supplied type is not formattable - 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); - | ^~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:214:54: note: in instantiation of function template specialization 'std::__format::__create_format_arg>' requested here - 214 | basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:249:19: note: in instantiation of function template specialization 'std::__format::__create_packed_storage>' requested here - 249 | __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_functions.h:70:10: note: in instantiation of member function 'std::__format_arg_store>::__format_arg_store' requested here - 70 | return _VSTD::__format_arg_store<_Context, _Args...>(__args...); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__config:880:17: note: expanded from macro '_VSTD' - 880 | # define _VSTD std - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:331:59: note: in instantiation of function template specialization 'std::make_format_args>' requested here - 331 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:341:8: note: in instantiation of function template specialization 'std::print>' requested here - 341 | std::print(stdout, __fmt, std::forward<_Args>(__args)...); - | ^ -mixed-type-safety-1.cpp2:18:5: note: in instantiation of function template specialization 'std::print>' requested here - 18 | print( "1 is int?", cpp2::impl::is(1)); - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:167:23: note: expression evaluates to '0 != 0' - 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); - | ~~~~~~^~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:169:17: error: static assertion failed - 169 | static_assert(__formattable_with<_Tp, _Context>); - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:169:17: note: because '__formattable_with, std::format_context>' evaluated to false -/usr/lib/llvm-18/bin/../include/c++/v1/__format/concepts.h:49:5: note: because 'std::formatter>' does not satisfy 'semiregular' - 49 | semiregular<_Formatter> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/semiregular.h:27:23: note: because 'std::formatter>' does not satisfy 'copyable' - 27 | concept semiregular = copyable<_Tp> && default_initializable<_Tp>; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/copyable.h:30:5: note: because 'std::formatter>' does not satisfy 'copy_constructible' - 30 | copy_constructible<_Tp> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:45:5: note: because 'std::formatter>' does not satisfy 'move_constructible' - 45 | move_constructible<_Tp> && - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:39:30: note: because 'constructible_from >, std::formatter > >' evaluated to false - 39 | concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/__concepts/constructible.h:27:51: note: because 'is_constructible_v >, std::formatter > >' evaluated to false - 27 | concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; - | ^ -In file included from mixed-type-safety-1.cpp:6: -In file included from ../../../include/cpp2util.h:277: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/iostream:44: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/istream:170: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/ostream:189: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/format:195: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/container_adaptor.h:20: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_default_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/range_formatter.h:23: -In file included from /usr/lib/llvm-18/bin/../include/c++/v1/__format/format_context.h:18: -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg_store.h:205:12: error: no matching constructor for initialization of 'basic_format_arg' - 205 | return basic_format_arg<_Context>{__arg, __value}; - | ^ ~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:251:34: note: candidate constructor not viable: no known conversion from 'std::integral_constant' to '__basic_format_arg_value' for 2nd argument - 251 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type, - | ^ - 252 | __basic_format_arg_value<_Context> __value) noexcept - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided - 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { - | ^~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided - 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { - | ^~~~~~~~~~~~~~~~ -/usr/lib/llvm-18/bin/../include/c++/v1/__format/format_arg.h:229:25: note: candidate constructor not viable: requires 0 arguments, but 2 were provided - 229 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {} - | ^ -10 errors generated. diff --git a/regression-tests/test-results/clang-18-c++23-libcpp/pure2-type-safety-1.cpp.output b/regression-tests/test-results/clang-18-c++23-libcpp/pure2-type-safety-1.cpp.output deleted file mode 100644 index 683ae42de..000000000 --- a/regression-tests/test-results/clang-18-c++23-libcpp/pure2-type-safety-1.cpp.output +++ /dev/null @@ -1,25 +0,0 @@ -pure2-type-safety-1.cpp2:26:5: error: call to 'print' is ambiguous - 26 | print(cpp2::move(msgx) + " is int? ", cpp2::impl::is(x)); - | ^~~~~ -pure2-type-safety-1.cpp2:8:5: note: in instantiation of function template specialization 'test_generic' requested here - 8 | test_generic(3.14, "double"); - | ^ -pure2-type-safety-1.cpp2:29:6: note: candidate function - 29 | auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:340:28: note: candidate function [with _Args = >] - 340 | _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __args) { - | ^ -pure2-type-safety-1.cpp2:26:5: error: call to 'print' is ambiguous - 26 | print(cpp2::move(msgx) + " is int? ", cpp2::impl::is(x)); - | ^~~~~ -pure2-type-safety-1.cpp2:18:5: note: in instantiation of function template specialization 'test_generic' requested here - 18 | test_generic(42, "int"); - | ^ -pure2-type-safety-1.cpp2:29:6: note: candidate function - 29 | auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void; - | ^ -/usr/lib/llvm-18/bin/../include/c++/v1/print:340:28: note: candidate function [with _Args = >] - 340 | _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __args) { - | ^ -2 errors generated. diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-type-safety-1.cpp.output b/regression-tests/test-results/gcc-14-c++2b/pure2-type-safety-1.cpp.output deleted file mode 100644 index 3b2b1e097..000000000 --- a/regression-tests/test-results/gcc-14-c++2b/pure2-type-safety-1.cpp.output +++ /dev/null @@ -1,16 +0,0 @@ -pure2-type-safety-1.cpp2: In instantiation of ‘void test_generic(const auto:110&, const auto:111&) [with auto:110 = double; auto:111 = char [7]]’: -pure2-type-safety-1.cpp2:8:17: required from here -pure2-type-safety-1.cpp2:26:10: error: call of overloaded ‘print(std::__cxx11::basic_string, std::integral_constant)’ is ambiguous -In file included from ../../../include/cpp2util.h:190, - from pure2-type-safety-1.cpp:7: -/usr/include/c++/14/print:115:5: note: candidate: ‘void std::print(format_string<_Args ...>, _Args&& ...) [with _Args = {integral_constant}; format_string<_Args ...> = basic_format_string >]’ - 115 | print(format_string<_Args...> __fmt, _Args&&... __args) - | ^~~~~ -pure2-type-safety-1.cpp2:29:6: note: candidate: ‘void print(cpp2::impl::in >, cpp2::impl::in)’ -pure2-type-safety-1.cpp2: In instantiation of ‘void test_generic(const auto:110&, const auto:111&) [with auto:110 = int; auto:111 = char [4]]’: -pure2-type-safety-1.cpp2:18:17: required from here -pure2-type-safety-1.cpp2:26:10: error: call of overloaded ‘print(std::__cxx11::basic_string, std::integral_constant)’ is ambiguous -/usr/include/c++/14/print:115:5: note: candidate: ‘void std::print(format_string<_Args ...>, _Args&& ...) [with _Args = {integral_constant}; format_string<_Args ...> = basic_format_string >]’ - 115 | print(format_string<_Args...> __fmt, _Args&&... __args) - | ^~~~~ -pure2-type-safety-1.cpp2:29:6: note: candidate: ‘void print(cpp2::impl::in >, cpp2::impl::in)’ diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp index eb1427822..aeddfbbaf 100644 --- a/regression-tests/test-results/mixed-type-safety-1.cpp +++ b/regression-tests/test-results/mixed-type-safety-1.cpp @@ -38,13 +38,15 @@ template auto print(cpp2::impl::in msg, T const& x) -> #line 15 "mixed-type-safety-1.cpp2" [[nodiscard]] auto main() -> int { - print("1.1 is int?", cpp2::impl::is(1.1)); - print( "1 is int?", cpp2::impl::is(1)); + // Full qualification is necessary to avoid ambiguity in C++23 + // C++23 defines std::print, which would be picked up here by ADL + ::print("1.1 is int?", cpp2::impl::is(1.1)); + ::print( "1 is int?", cpp2::impl::is(1)); auto c {cpp2_new()}; // safe by construction Shape* s {CPP2_UFCS(get)(cpp2::move(c))}; // safe by Lifetime - print("\ns* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); - print( "s* is Circle?", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); - print( "s* is Square?", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); + ::print("\ns* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + ::print( "s* is Circle?", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + ::print( "s* is Square?", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); } diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-type-safety-1.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-type-safety-1.cpp.output index 4e23eda77..cdc655933 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-type-safety-1.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-type-safety-1.cpp.output @@ -1,12 +1 @@ pure2-type-safety-1.cpp -pure2-type-safety-1.cpp2(26): error C2666: 'print': overloaded functions have similar conversions -pure2-type-safety-1.cpp2(29): note: could be 'void print(const std::string &,const bool)' -C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\print(125): note: or 'void std::print(const std::basic_format_string>,std::false_type &&)' [found using argument-dependent lookup] -pure2-type-safety-1.cpp2(26): note: while trying to match the argument list '(std::basic_string,std::allocator>, std::false_type)' -pure2-type-safety-1.cpp2(26): note: the template instantiation context (the oldest one first) is -pure2-type-safety-1.cpp2(8): note: see reference to function template instantiation 'void test_generic(const _T0 &,const _T1 (&))' being compiled - with - [ - _T0=double, - _T1=char [7] - ] diff --git a/regression-tests/test-results/pure2-type-safety-1.cpp b/regression-tests/test-results/pure2-type-safety-1.cpp index 06d4b0c7e..10d7e38c9 100644 --- a/regression-tests/test-results/pure2-type-safety-1.cpp +++ b/regression-tests/test-results/pure2-type-safety-1.cpp @@ -19,9 +19,9 @@ #line 24 "pure2-type-safety-1.cpp2" auto test_generic(auto const& x, auto const& msg) -> void; -#line 29 "pure2-type-safety-1.cpp2" +#line 31 "pure2-type-safety-1.cpp2" auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void; -#line 35 "pure2-type-safety-1.cpp2" +#line 37 "pure2-type-safety-1.cpp2" #line 1 "pure2-type-safety-1.cpp2" @@ -55,10 +55,12 @@ auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void; #line 24 "pure2-type-safety-1.cpp2" auto test_generic(auto const& x, auto const& msg) -> void{ std::string msgx {msg}; - print(cpp2::move(msgx) + " is int? ", cpp2::impl::is(x)); + // Full qualification is necessary to avoid ambiguity in C++23 + // C++23 defines std::print, which would be picked up here by ADL + ::print(cpp2::move(msgx) + " is int? ", cpp2::impl::is(x)); } -#line 29 "pure2-type-safety-1.cpp2" +#line 31 "pure2-type-safety-1.cpp2" auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void{ cpp2::impl::deferred_init bmsg; if (b) { bmsg.construct("true");}