GCC 4.x error: no matching function for call to ‘size(const char* const&)’
dawid-s opened this issue · 10 comments
So I used 'dbg.h' in the past in the same project and had no issues building but now I am getting the following error:
/usr/include/dbg.h: In substitution of ‘template<class T> using detect_size_t = decltype (dbg::detail::{anonymous}::size(declval<T>())) [with T = const char* const&]’:
/usr/include/dbg.h:283:27: required from ‘struct dbg::detail_detector::detector<dbg::detail_detector::nonesuch, void, dbg::detail::det
ect_size_t, const char* const&>’
/usr/include/dbg.h:290:68: required by substitution of ‘template<template<class ...> class Op, class ... Args> using is_detected = typ
ename dbg::detail_detector::detector<dbg::detail_detector::nonesuch, void, Op, Args ...>::value_t [with Op = dbg::detail::detect_size_t;
Args = {const char* const&}]’
/usr/include/dbg.h:324:43: required from ‘constexpr const bool dbg::detail::is_container<const char* const&>::value’
/usr/include/dbg.h:363:32: required by substitution of ‘template<class T> typename std::enable_if<((! dbg::detail::is_container<const T&>::value) && (! std::is_enum<_Tp>::value)), bool>::type dbg::pretty_print(std::ostream&, const T&) [with T = const char*]’
/usr/include/dbg.h:421:72: required from here /usr/include/dbg.h:318:62: error: no matching function for call to ‘size(const char* const&)’
using detect_size_t = decltype(detail::size(std::declval<T>()));
I installed the header file as suggested in /usr/include/dbg.h
.
Thank you for reporting this. Which compiler and version are you using?
And how do you call dbg?
I build it on CentoOS 7 with GCC 4.8.5. In order for me to get the error, I don't even need to call it. It is enough that I add the header to the translation unit I want to use it in.
I can reproduce this via https://godbolt.org/
The error seems to appear for GCC versions 4.x. Everything works fine for GCC 5.x and higher.
GCC 5 has been available for over five years now, so I'm not sure if we really need to support GCC 4 as well. If someone wants to work on this, that would be great, but I'm personally not going to look into it.
@dawid-s Thank you for sharing this anyway.
No worries. Thanks for confirming what is the issue. I might just be able to compile with a higher version of the compiler for debugging purposes. Great project btw.
If it comes to versions of compilers, some industries are moving quite slowly, to be honest, only this year we will move to C++ 14 and GCC 6.3.
If it comes to versions of compilers, some industries are moving quite slowly, to be honest, only this year we will move to C++ 14 and GCC 6.3.
You are absolutely right. I have made similar experiences on my own 😄.
Let's keep this issue open for a while in case someone might be able to fix this.
Just ran into this myself this morning - so glad that it's being tracked!
I attempted to solve this a few times, but didn't get very far. Any help would be appreciated.
Note: I don't want to completely replace the nice is_detected
mechanism with something else just to fix this bug on old GCC versions.
GCC 4 was released in 2005. I think we close this for now. I don't think someone will work on resolving an issue with a compiler that is 18 years old