Skip to content

Failure to compile with gcc-13: call of overloaded 'format(..)' is ambiguous #418

Description

@Wentzell

I am trying to compile ITensor v3 (fe8459a) on OSX 13.4 using gcc-13 as installed through homebrew.

This currently fails due to an ambiguity in calls to format(const char [6], std::string&).

See full compiler error error below

Compiling itensor/tensor/vec.cc in debug mode
In file included from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/ten.h:905,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/vec.h:20,
                 from tensor/vec.cc:18:
/Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/ten_impl.h: In function 'void itensor::checkCompatible(const TenRefc<range_type_, value_type_>&, const TenRefc<R2, T2>&, std::string)':
/Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/ten_impl.h:97:48: error: call of overloaded 'format(const char [6], std::string&)' is ambiguous
   97 |     auto methodstr = (methodName != "" ? format("in %s",methodName) : "");
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/util/print.h:19,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/types.h:22,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/detail/algs.h:25,
                 from tensor/vec.cc:17:
/Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/util/tinyformat.h:893:13: note: candidate: 'std::string tinyformat::format(const char*, const Args& ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::string = std::__cxx11::basic_string<char>]'
  893 | std::string format(const char* fmt, const Args&... args)
      |             ^~~~~~
In file included from /opt/homebrew/Cellar/gcc/13.1.0/include/c++/13/bits/chrono_io.h:39,
                 from /opt/homebrew/Cellar/gcc/13.1.0/include/c++/13/chrono:3330,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/util/timers.h:19,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/types.h:24,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/util/readwrite.h:24,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/range.h:20,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/vecrange.h:22,
                 from /Users/nwentzell/Dropbox/Coding/ITensorOSX/itensor/tensor/vec.h:19:
/opt/homebrew/Cellar/gcc/13.1.0/include/c++/13/format:3713:5: note: candidate: 'std::string std::format(format_string<_Args ...>, _Args&& ...) [with _Args = {__cxx11::basic_string<char, char_traits<char>, allocator<char> >&}; string = __cxx11::basic_string<char>; format_string<_Args ...> = basic_format_string<char, __cxx11::basic_string<char, char_traits<char>, allocator<char> >&>]'
 3713 |     format(format_string<_Args...> __fmt, _Args&&... __args)
      |     ^~~~~~

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