cannot pass object of non-trivial type 'const rediscpp::resp::deserialization::error_message' through variadic function
slhck opened this issue · 2 comments
slhck commented
I have a simple example:
#include <iostream>
#define REDISCPP_HEADER_ONLY
#include <redis-cpp/stream.h>
#include <redis-cpp/execute.h>
int main(int argc, char *argv[])
{
try
{
auto stream = rediscpp::make_stream(
"localhost",
"6379"
);
auto const key = "my_key";
auto response = rediscpp::execute(*stream, "set",
key, "Some value for 'my_key'", "ex", "60");
std::cout << "Set key '" << key << "': " << response.as<std::string>() << std::endl;
response = rediscpp::execute(*stream, "get", key);
std::cout << "Get key '" << key << "': " << response.as<std::string>() << std::endl;
response = rediscpp::execute(*stream, "del", key);
std::cout << "Deleted key '" << key << "': " << response.as<std::string>() << std::endl;
}
catch (std::exception const &e)
{
std::cerr << "Error: " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
When compiling this under macOS 10.15.7, I get:
➜ meson compile -C builddir
ninja: Entering directory `builddir'
[1/2] Compiling C++ object redis_test.p/src_redis_test.cpp.o
FAILED: redis_test.p/src_redis_test.cpp.o
c++ -Iredis_test.p -I. -I.. -I../include/redis-cpp -I../include -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -std=c++17 -g -MD -MQ redis_test.p/src_redis_test.cpp.o -MF redis_test.p/src_redis_test.cpp.o.d -o redis_test.p/src_redis_test.cpp.o -c ../src/redis_test.cpp
In file included from ../src/redis_test.cpp:5:
In file included from ../include/redis-cpp/execute.h:21:
../include/redis-cpp/value.h:203:33: error: cannot pass object of non-trivial type 'const rediscpp::resp::deserialization::error_message' through variadic function; call will abort at runtime [-Wnon-pod-varargs]
if (is_null(val))
^
../include/redis-cpp/value.h:116:16: note: in instantiation of function template specialization 'rediscpp::value::get_value<std::__1::basic_string_view<char, std::__1::char_traits<char> >, rediscpp::resp::deserialization::error_message>' requested here
return get_value<std::string_view, resp::deserialization::error_message>();
^
../include/redis-cpp/value.h:203:33: error: cannot pass object of non-trivial type 'const rediscpp::resp::deserialization::simple_string' through variadic function; call will abort at runtime [-Wnon-pod-varargs]
if (is_null(val))
^
../include/redis-cpp/value.h:122:16: note: in instantiation of function template specialization 'rediscpp::value::get_value<std::__1::basic_string_view<char, std::__1::char_traits<char> >, rediscpp::resp::deserialization::simple_string>' requested here
return get_value<std::string_view, resp::deserialization::simple_string>();
^
2 errors generated.
ninja: build stopped: subcommand failed.
More info on the compiler:
➜ c++ --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Any idea what the problem could be?
tdv commented
I've just fixed that for c++ 17 implementations within ubuntu and clang 10. Hopefully, it'll work and on MacOS.
Please, try it and report the result.
Good luck.
Regards.
slhck commented
It works now, thank you for the quick response!