-
Notifications
You must be signed in to change notification settings - Fork 264
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Title. This one has different effects on different compilers.
To Reproduce
Steps to reproduce the behavior:
- Sample code - distilled down to minimal essentials please
#include <filesystem>
my_enum: @enum type = {
foo;
bar;
}
aaa: () -> std::string = {
a := my_enum::foo;
return "(a)$";
}
bbb: () -> std::string = {
p: std::filesystem::path = ();
return "(p)$";
}
main: () = std::cout << aaa() << bbb();- Command lines including which C++ compiler you are using
Clang 17:-std=c++20 -Wall -Wextra -pedantic -Werror
MSVC:/std:c++latest /MD /EHsc /experimental:module /W4 /WX - Expected result - what you expected to happen
I would expect these to compile on all compilers, they seem to work in GCC 14. But non-GCC compilers seem unhappy about it. - Actual result/error
On clang I get the following:
error: cannot pass object of non-trivial type 'typename std::remove_reference<my_enum &>::type' (aka 'my_enum') through variadic function; call will abort at runtime [-Wnon-pod-varargs]
63 | return { cpp2::to_string(cpp2::move(a)) };
| ^
1 error generated.
On MSVC I get roughly:
error C2220: the following warning is treated as an error
warning C4840: non-portable use of class 'std::filesystem::path' as an argument to a variadic function
note: 'std::filesystem::path::path' is non-trivial
note: see declaration of 'std::filesystem::path::path'
note: the constructor and destructor will not be called; a bitwise copy of the class will be passed as the argument
note: see declaration of 'std::filesystem::path'
So the @enum case seems to fail in clang (presumably because it defines a to_string member function?) and the std::filesystem::path case seems to fail on MSVC. This latter one I have no idea whats wrong.
Additional context
For the @enum case, calling to_string directly seems to workaround the issue, although that mostly makes the string interpolation redundant.
Initially I thought about opening an issue for each case, but they seem very related. Also I think these have to do with the definition at cpp2util.h:1192.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working