isis-group / isis

The ISIS project aims to provide a framework to access a large variety of image processing libraries written in different programming languages and environments.
GNU General Public License v3.0
17 stars 14 forks source link

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

Open musicinmybrain opened 1 year ago

musicinmybrain commented 1 year ago

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.