p4c icon indicating copy to clipboard operation
p4c copied to clipboard

Implement basic toString method for ebpf types.

Open fruffy opened this issue 4 months ago • 3 comments

Hopefully fixes #5370.

@jkhsjdhjs Can you give this a try?

The right way to solve this is to add virtual cstring node_type_name() const = 0; to the ICastable class and invoke it in the checkedTo call. But this might be a breaking change...

fruffy avatar Aug 30 '25 10:08 fruffy

Unfortunately I still see the same error with this patch:

In file included from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:29,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/ir/id.h:21,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/build/ir/ir-generated.h:10,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/ir/ir.h:21,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/frontends/common/programMap.h:20,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/frontends/p4/typeMap.h:22,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/codeGen.h:20,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/ebpfObject.h:20,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/ebpfBackend.h:20,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/p4c-ebpf.cpp:24,
                 from /home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/build/backends/ebpf/CMakeFiles/p4c-ebpf.dir/Unity/unity_0_cxx.cxx:4:
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h: In instantiation of ‘std::ostream& P4::detail::operator<<(std::ostream&, const DbprintDispatchPtr<T>&) [with T = P4::ApplyMethod; std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/format/feed_args.hpp:99:12:   required from ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits<char>; T = P4::detail::DbprintDispatchPtr<P4::ApplyMethod>]’
   99 |         os << x ;
      |         ~~~^~~~
/usr/include/boost/format/feed_args.hpp:126:17:   required from ‘void boost::io::detail::call_put_last(std::basic_ostream<_CharT, _Traits>&, const void*) [with Ch = char; Tr = std::char_traits<char>; T = const P4::detail::DbprintDispatchPtr<P4::ApplyMethod>]’
  126 |         put_last(os, *(static_cast<T const *>(x)));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:135:22:   required from ‘boost::io::detail::put_holder<Ch, Tr>::put_holder(T&) [with T = const P4::detail::DbprintDispatchPtr<P4::ApplyMethod>; Ch = char; Tr = std::char_traits<char>]’
  135 |             put_last(&call_put_last<Ch, Tr, T>)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:313:74:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::io::detail::feed(boost::basic_format<Ch, Tr, Alloc>&, T) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; T = const P4::detail::DbprintDispatchPtr<P4::ApplyMethod>&]’
  313 |         return feed_impl<Ch, Tr, Alloc, const put_holder<Ch, Tr>&>(self, put_holder<Ch, Tr>(x));
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/format_class.hpp:64:66:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::basic_format<Ch, Tr, Alloc>::operator%(const T&) [with T = P4::detail::DbprintDispatchPtr<P4::ApplyMethod>; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>]’
   64 |             { return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x); }
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:113:25:   required from ‘auto P4::detail::bug_helper(boost::format&, std::string_view, std::string_view, const T*, Args&& ...) [with T = P4::ApplyMethod; Args = {}; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  113 |     return bug_helper(f % DbprintDispatchPtr<T>{t}, outPos, outTail, std::forward<Args>(args)...);
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:146:30:   required from ‘std::string P4::bug_helper(boost::format&, std::string_view, std::string_view, Args&& ...) [with Args = {const ApplyMethod*&}; std::string = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  146 |     return detail::bug_helper(f, position, tail, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:82:35:   required from ‘P4::Util::P4CExceptionBase::P4CExceptionBase(const char*, Args&& ...) [with Args = {const P4::ApplyMethod*&}]’
   82 |         message = ::P4::bug_helper(fmt, "", "", std::forward<Args>(args)...);
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:102:63:   required from ‘P4::Util::CompilerBug::CompilerBug(int, const char*, const char*, Args&& ...) [with Args = {const P4::ApplyMethod*&}]’
  102 |         : P4CExceptionBase(format, std::forward<Args>(args)...) {
      |                                                               ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/ebpfControl.cpp:320:5:   required from here
  140 |         throw P4::Util::CompilerBug(__LINE__, __FILE__, __VA_ARGS__); \
      |                                                                    ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:99:23: error: static assertion failed: cannot debug print this type, implement dbprint method
   99 |         static_assert(has_ostream_operator_v<decltype(dispatch.val)>,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:99:23: note: ‘P4::has_ostream_operator_v<const P4::ApplyMethod*>’ evaluates to false
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h: In instantiation of ‘std::ostream& P4::detail::operator<<(std::ostream&, const DbprintDispatchRef<T>&) [with T = long unsigned int; std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/format/feed_args.hpp:99:12:   required from ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits<char>; T = P4::detail::DbprintDispatchRef<long unsigned int>]’
   99 |         os << x ;
      |         ~~~^~~~
/usr/include/boost/format/feed_args.hpp:126:17:   required from ‘void boost::io::detail::call_put_last(std::basic_ostream<_CharT, _Traits>&, const void*) [with Ch = char; Tr = std::char_traits<char>; T = const P4::detail::DbprintDispatchRef<long unsigned int>]’
  126 |         put_last(os, *(static_cast<T const *>(x)));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:135:22:   required from ‘boost::io::detail::put_holder<Ch, Tr>::put_holder(T&) [with T = const P4::detail::DbprintDispatchRef<long unsigned int>; Ch = char; Tr = std::char_traits<char>]’
  135 |             put_last(&call_put_last<Ch, Tr, T>)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:313:74:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::io::detail::feed(boost::basic_format<Ch, Tr, Alloc>&, T) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; T = const P4::detail::DbprintDispatchRef<long unsigned int>&]’
  313 |         return feed_impl<Ch, Tr, Alloc, const put_holder<Ch, Tr>&>(self, put_holder<Ch, Tr>(x));
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/format_class.hpp:64:66:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::basic_format<Ch, Tr, Alloc>::operator%(const T&) [with T = P4::detail::DbprintDispatchRef<long unsigned int>; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>]’
   64 |             { return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x); }
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:138:25:   required from ‘std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > P4::detail::bug_helper(boost::format&, std::string_view, std::string_view, const T&, Args&& ...) [with T = long unsigned int; Args = {long unsigned int}; std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  138 |     return bug_helper(f % DbprintDispatchRef<T>{t}, outPos, outTail, std::forward<Args>(args)...);
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:146:30:   required from ‘std::string P4::bug_helper(boost::format&, std::string_view, std::string_view, Args&& ...) [with Args = {long unsigned int, long unsigned int}; std::string = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  146 |     return detail::bug_helper(f, position, tail, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:82:35:   required from ‘P4::Util::P4CExceptionBase::P4CExceptionBase(const char*, Args&& ...) [with Args = {long unsigned int, long unsigned int}]’
   82 |         message = ::P4::bug_helper(fmt, "", "", std::forward<Args>(args)...);
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:102:63:   required from ‘P4::Util::CompilerBug::CompilerBug(int, const char*, const char*, Args&& ...) [with Args = {long unsigned int, long unsigned int}]’
  102 |         : P4CExceptionBase(format, std::forward<Args>(args)...) {
      |                                                               ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/ir/type.def:253:9:   required from here
  140 |         throw P4::Util::CompilerBug(__LINE__, __FILE__, __VA_ARGS__); \
      |                                                                    ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: error: static assertion failed: cannot debug print this type, implement dbprint method
  126 |         static_assert(has_ostream_operator_v<decltype(dispatch.val)>,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: note: ‘P4::has_ostream_operator_v<const long unsigned int&>’ evaluates to false
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h: In instantiation of ‘std::ostream& P4::detail::operator<<(std::ostream&, const DbprintDispatchRef<T>&) [with T = unsigned int; std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/format/feed_args.hpp:99:12:   required from ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits<char>; T = P4::detail::DbprintDispatchRef<unsigned int>]’
   99 |         os << x ;
      |         ~~~^~~~
/usr/include/boost/format/feed_args.hpp:126:17:   required from ‘void boost::io::detail::call_put_last(std::basic_ostream<_CharT, _Traits>&, const void*) [with Ch = char; Tr = std::char_traits<char>; T = const P4::detail::DbprintDispatchRef<unsigned int>]’
  126 |         put_last(os, *(static_cast<T const *>(x)));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:135:22:   required from ‘boost::io::detail::put_holder<Ch, Tr>::put_holder(T&) [with T = const P4::detail::DbprintDispatchRef<unsigned int>; Ch = char; Tr = std::char_traits<char>]’
  135 |             put_last(&call_put_last<Ch, Tr, T>)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:313:74:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::io::detail::feed(boost::basic_format<Ch, Tr, Alloc>&, T) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; T = const P4::detail::DbprintDispatchRef<unsigned int>&]’
  313 |         return feed_impl<Ch, Tr, Alloc, const put_holder<Ch, Tr>&>(self, put_holder<Ch, Tr>(x));
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/format_class.hpp:64:66:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::basic_format<Ch, Tr, Alloc>::operator%(const T&) [with T = P4::detail::DbprintDispatchRef<unsigned int>; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>]’
   64 |             { return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x); }
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:138:25:   required from ‘std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > P4::detail::bug_helper(boost::format&, std::string_view, std::string_view, const T&, Args&& ...) [with T = unsigned int; Args = {}; std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  138 |     return bug_helper(f % DbprintDispatchRef<T>{t}, outPos, outTail, std::forward<Args>(args)...);
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:146:30:   required from ‘std::string P4::bug_helper(boost::format&, std::string_view, std::string_view, Args&& ...) [with Args = {unsigned int&}; std::string = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  146 |     return detail::bug_helper(f, position, tail, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:82:35:   required from ‘P4::Util::P4CExceptionBase::P4CExceptionBase(const char*, Args&& ...) [with Args = {unsigned int&}]’
   82 |         message = ::P4::bug_helper(fmt, "", "", std::forward<Args>(args)...);
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:102:63:   required from ‘P4::Util::CompilerBug::CompilerBug(int, const char*, const char*, Args&& ...) [with Args = {unsigned int&}]’
  102 |         : P4CExceptionBase(format, std::forward<Args>(args)...) {
      |                                                               ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/ebpfControl.cpp:189:9:   required from here
  140 |         throw P4::Util::CompilerBug(__LINE__, __FILE__, __VA_ARGS__); \
      |                                                                    ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: error: static assertion failed: cannot debug print this type, implement dbprint method
  126 |         static_assert(has_ostream_operator_v<decltype(dispatch.val)>,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: note: ‘P4::has_ostream_operator_v<const unsigned int&>’ evaluates to false
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h: In instantiation of ‘std::ostream& P4::detail::operator<<(std::ostream&, const DbprintDispatchRef<T>&) [with T = P4::EBPF::TableKind; std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/format/feed_args.hpp:99:12:   required from ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits<char>; T = P4::detail::DbprintDispatchRef<P4::EBPF::TableKind>]’
   99 |         os << x ;
      |         ~~~^~~~
/usr/include/boost/format/feed_args.hpp:126:17:   required from ‘void boost::io::detail::call_put_last(std::basic_ostream<_CharT, _Traits>&, const void*) [with Ch = char; Tr = std::char_traits<char>; T = const P4::detail::DbprintDispatchRef<P4::EBPF::TableKind>]’
  126 |         put_last(os, *(static_cast<T const *>(x)));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:135:22:   required from ‘boost::io::detail::put_holder<Ch, Tr>::put_holder(T&) [with T = const P4::detail::DbprintDispatchRef<P4::EBPF::TableKind>; Ch = char; Tr = std::char_traits<char>]’
  135 |             put_last(&call_put_last<Ch, Tr, T>)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:313:74:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::io::detail::feed(boost::basic_format<Ch, Tr, Alloc>&, T) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; T = const P4::detail::DbprintDispatchRef<P4::EBPF::TableKind>&]’
  313 |         return feed_impl<Ch, Tr, Alloc, const put_holder<Ch, Tr>&>(self, put_holder<Ch, Tr>(x));
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/format_class.hpp:64:66:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::basic_format<Ch, Tr, Alloc>::operator%(const T&) [with T = P4::detail::DbprintDispatchRef<P4::EBPF::TableKind>; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>]’
   64 |             { return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x); }
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:138:25:   required from ‘std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > P4::detail::bug_helper(boost::format&, std::string_view, std::string_view, const T&, Args&& ...) [with T = P4::EBPF::TableKind; Args = {}; std::enable_if_t<((bool)(! is_pointer_v<T>)), std::__cxx11::basic_string<char> > = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  138 |     return bug_helper(f % DbprintDispatchRef<T>{t}, outPos, outTail, std::forward<Args>(args)...);
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:146:30:   required from ‘std::string P4::bug_helper(boost::format&, std::string_view, std::string_view, Args&& ...) [with Args = {EBPF::TableKind&}; std::string = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  146 |     return detail::bug_helper(f, position, tail, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:82:35:   required from ‘P4::Util::P4CExceptionBase::P4CExceptionBase(const char*, Args&& ...) [with Args = {P4::EBPF::TableKind&}]’
   82 |         message = ::P4::bug_helper(fmt, "", "", std::forward<Args>(args)...);
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:102:63:   required from ‘P4::Util::CompilerBug::CompilerBug(int, const char*, const char*, Args&& ...) [with Args = {P4::EBPF::TableKind&}]’
  102 |         : P4CExceptionBase(format, std::forward<Args>(args)...) {
      |                                                               ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/target.cpp:110:9:   required from here
  140 |         throw P4::Util::CompilerBug(__LINE__, __FILE__, __VA_ARGS__); \
      |                                                                    ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: error: static assertion failed: cannot debug print this type, implement dbprint method
  126 |         static_assert(has_ostream_operator_v<decltype(dispatch.val)>,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:126:23: note: ‘P4::has_ostream_operator_v<const P4::EBPF::TableKind&>’ evaluates to false
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h: In instantiation of ‘std::ostream& P4::detail::operator<<(std::ostream&, const DbprintDispatchPtr<T>&) [with T = P4::ICastable; std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/format/feed_args.hpp:99:12:   required from ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits<char>; T = P4::detail::DbprintDispatchPtr<P4::ICastable>]’
   99 |         os << x ;
      |         ~~~^~~~
/usr/include/boost/format/feed_args.hpp:126:17:   required from ‘void boost::io::detail::call_put_last(std::basic_ostream<_CharT, _Traits>&, const void*) [with Ch = char; Tr = std::char_traits<char>; T = const P4::detail::DbprintDispatchPtr<P4::ICastable>]’
  126 |         put_last(os, *(static_cast<T const *>(x)));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:135:22:   required from ‘boost::io::detail::put_holder<Ch, Tr>::put_holder(T&) [with T = const P4::detail::DbprintDispatchPtr<P4::ICastable>; Ch = char; Tr = std::char_traits<char>]’
  135 |             put_last(&call_put_last<Ch, Tr, T>)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/feed_args.hpp:313:74:   required from ‘boost::basic_format<Ch, Tr, Alloc>& boost::io::detail::feed(boost::basic_format<Ch, Tr, Alloc>&, T) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; T = const P4::detail::DbprintDispatchPtr<P4::ICastable>&]’
  313 |         return feed_impl<Ch, Tr, Alloc, const put_holder<Ch, Tr>&>(self, put_holder<Ch, Tr>(x));
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/format/format_class.hpp:64:66:   [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:146:30:   required from ‘std::string P4::bug_helper(boost::format&, std::string_view, std::string_view, Args&& ...) [with Args = {ICastable*, const char*}; std::string = std::__cxx11::basic_string<char>; boost::format = boost::basic_format<char>; std::string_view = std::basic_string_view<char>]’
  146 |     return detail::bug_helper(f, position, tail, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:82:35:   required from ‘P4::Util::P4CExceptionBase::P4CExceptionBase(const char*, Args&& ...) [with Args = {P4::ICastable*, const char*}]’
   82 |         message = ::P4::bug_helper(fmt, "", "", std::forward<Args>(args)...);
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/exceptions.h:102:63:   required from ‘P4::Util::CompilerBug::CompilerBug(int, const char*, const char*, Args&& ...) [with Args = {P4::ICastable*, const char*}]’
  102 |         : P4CExceptionBase(format, std::forward<Args>(args)...) {
      |                                                               ^
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/castable.h:64:9:   required from ‘T* P4::ICastable::checkedTo() [with T = P4::EBPF::IHasWidth]’
  140 |         throw P4::Util::CompilerBug(__LINE__, __FILE__, __VA_ARGS__); \
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/castable.h:49:29:   required from ‘T& P4::ICastable::as() [with T = P4::EBPF::IHasWidth]’
   49 |         return *checkedTo<T>();
      |                 ~~~~~~~~~~~~^~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/backends/ebpf/ebpfTable.cpp:544:50:   required from here
  544 |             unsigned width = etype->as<IHasWidth>().widthInBits();
      |                              ~~~~~~~~~~~~~~~~~~~~^~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:99:23: error: static assertion failed: cannot debug print this type, implement dbprint method
   99 |         static_assert(has_ostream_operator_v<decltype(dispatch.val)>,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jkhsjdhjs/aur/p4lang-p4c/src/p4c-1.2.5.8/lib/bug_helper.h:99:23: note: ‘P4::has_ostream_operator_v<const P4::ICastable*>’ evaluates to false
make[2]: *** [backends/ebpf/CMakeFiles/p4c-ebpf.dir/build.make:107: backends/ebpf/CMakeFiles/p4c-ebpf.dir/Unity/unity_0_cxx.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:2959: backends/ebpf/CMakeFiles/p4c-ebpf.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

jkhsjdhjs avatar Aug 30 '25 14:08 jkhsjdhjs

Unfortunately I still see the same error with this patch:

Can not reproduce this... which compiler are you using? Might also be caused by a different boost version

fruffy avatar Aug 30 '25 14:08 fruffy

I'm using

c++ (GCC) 15.2.1 20250813
boost 1.88.0
abseil 20250814.0
protobuf 32.0
cmake 4.1.1

I just did a clean build again to make sure it's not caused by the build cache, but I'm still able to reproduce this issue with the patch.

jkhsjdhjs avatar Aug 30 '25 14:08 jkhsjdhjs