https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94869

            Bug ID: 94869
           Summary: Template argument deduction/substitution failure with
                    Howard Hinnant's calendar library
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lcarreon at bigpond dot net.au
  Target Milestone: ---

The following bit of code used to compile ok with g++ 9.2.1.

#include <date.h>

int main()
{
    std::istringstream str{"2020-04-30 17:30:00.000"}; 
    std::chrono::local_time<std::chrono::milliseconds> loc_time;
    str >> date::parse("%Y-%m-%d %H:%M:%S", loc_time);
    return 0;
}

(NOTE: date.h is Howard Hinnant's sample implementation of the calendar library
included in C++20.)

However, when I compile with g++ 10.0.1 using this command line:

g++ -c -g -m64 -O3 -Wall -Werror -I/usr/local/include -std=c++2a dt.cpp

The compile fails with the following messages (excerpt only/incomplete):

dt.cpp:7:50: error: no matching function for call to ‘parse(const char [18],
std::chrono::local_time<std::chrono::duration<long int, std::ratio<1, 1000> >
>&)’
    7 |  str >> date::parse("%Y-%m-%d %H:%M:%S", loc_time);
      |                                                  ^
In file included from dt.cpp:1:
/usr/local/include/date.h:7827:1: note: candidate: ‘template<class Parsable,
class CharT, class Traits, class Alloc> decltype
((date::from_stream(declval<std::basic_istream<_CharT, _Traits>&>(),
format.c_str(), tp), date::parse_manip<Parsable, CharT, Traits, Alloc>{format,
tp})) date::parse(const std::__cxx11::basic_string<CharT, Traits, Alloc>&,
Parsable&)’
 7827 | parse(const std::basic_string<CharT, Traits, Alloc>& format, Parsable&
tp)
      | ^~~~~
/usr/local/include/date.h:7827:1: note:   template argument
deduction/substitution failed:
dt.cpp:7:50: note:   mismatched types ‘const std::__cxx11::basic_string<CharT,
Traits, Alloc>’ and ‘const char [18]’
    7 |  str >> date::parse("%Y-%m-%d %H:%M:%S", loc_time);
      |                                                  ^
In file included from dt.cpp:1:
/usr/local/include/date.h:7838:1: note: candidate: ‘template<class Parsable,
class CharT, class Traits, class Alloc> decltype
((date::from_stream(declval<std::basic_istream<_CharT, _Traits>&>(),
format.c_str(), tp, (& abbrev)), date::parse_manip<Parsable, CharT, Traits,
Alloc>{format, tp, (& abbrev)})) date::parse(const
std::__cxx11::basic_string<CharT, Traits, Alloc>&, Parsable&,
std::__cxx11::basic_string<CharT, Traits, Alloc>&)’
 7838 | parse(const std::basic_string<CharT, Traits, Alloc>& format, Parsable&
tp,
      | ^~~~~
/usr/local/include/date.h:7838:1: note:   template argument
deduction/substitution failed:
dt.cpp:7:50: note:   mismatched types ‘const std::__cxx11::basic_string<CharT,
Traits, Alloc>’ and ‘const char [18]’
    7 |  str >> date::parse("%Y-%m-%d %H:%M:%S", loc_time);

FYI, I will also notify Howard Hinnant of this issue because he might have a
clue as to the cause of the problem.

Reply via email to