Skip to content

Logging broken due to ambiguous overloads in C++11 and later #74

@musicinmybrain

Description

@musicinmybrain

I was looking at picking up a stalled effort to package this in NeuroFedora, and I encountered many compiler errors like the following on GCC 12.1.1.

Using the latest master from this repository:

In file included from /home/ben/src/forks/isis/lib/Core/CoreUtils/types.hpp:17,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/value_base.hpp:20,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/value.hpp:16,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/property.hpp:18,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/progparameter.hpp:22,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/application.hpp:27,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/application.cpp:23:
/home/ben/src/forks/isis/lib/Core/CoreUtils/vector.hpp:242:33: error: ISO C++17 does not allow dynamic exception specifications
  242 |         const this_class &norm()throw( std::invalid_argument ) {
      |                                 ^~~~~
/home/ben/src/forks/isis/lib/Core/CoreUtils/application.cpp: In member function ‘virtual bool isis::util::Application::init(int, char**, bool)’:
/home/ben/src/forks/isis/lib/Core/CoreUtils/application.cpp:88:39: error: ambiguous overload for ‘operator<<’ (operand types are ‘isis::util::Message’ and ‘const char [33]’)
   88 |                 LOG( Runtime, error ) << "Failed to parse the command line";
      |                                       ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          const char [33]
In file included from /home/ben/src/forks/isis/lib/Core/CoreUtils/log.hpp:18,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/common.hpp:30,
                 from /home/ben/src/forks/isis/lib/Core/CoreUtils/vector.hpp:20:
/home/ben/src/forks/isis/lib/Core/CoreUtils/message.hpp:75:39: note: candidate: ‘isis::util::Message& isis::util::Message::operator<<(T) [with T = const char*]’
   75 |         template<typename T> Message &operator << ( T val ) {
      |                                       ^~~~~~~~
/home/ben/src/forks/isis/lib/Core/CoreUtils/message.hpp:79:18: note: candidate: ‘isis::util::Message& isis::util::Message::operator<<(const isis::util::MSubject&)’
   79 |         Message &operator << ( const MSubject &subj ) {
      |                  ^~~~~~~~

It wasn’t immediately clear to me how best to resolve the ambiguity.

The logging code compiles as expected when I explicitly add -DCMAKE_CXX_STANDARD=98, although there are other unrelated compiler errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions