Skip to content

Build fix for ambiguity with gcc >= 14#866

Open
agmt wants to merge 1 commit intoHowardHinnant:masterfrom
agmt:gcc-14
Open

Build fix for ambiguity with gcc >= 14#866
agmt wants to merge 1 commit intoHowardHinnant:masterfrom
agmt:gcc-14

Conversation

@agmt
Copy link
Copy Markdown

@agmt agmt commented Feb 14, 2025

Resolves building with gcc-14 (-std=c++20):

In attempt to build:

#include <sstream>
#include <chrono>
#include <date/date.h>

int main() {
    std::istringstream Stream("2023-10-05 14:30:00");
    std::chrono::system_clock::time_point TimePoint;
    Stream >> date::parse("%F %T", TimePoint);
}

compiler reports a conflict of date/date.h with c++/14/bits/chrono_io.h:

date/include/date/date.h:8290:28: error: call of overloaded ‘from_stream(std::basic_istream<char>&, const char*&, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >&)’ is ambiguous
 8290 |     -> decltype(from_stream(std::declval<std::basic_istream<CharT>&>(), format, tp),
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

date/include/date/date.h:8025:1: note: candidate: ‘std::basic_istream<_CharT, _Traits>& date::from_stream(std::basic_istream<_CharT, _Traits>&, const CharT*, sys_time<Duration>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*, std::chrono::minutes*) [with Duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >; CharT = char; Traits = std::char_traits<char>; Alloc = std::allocator<char>; sys_time<Duration> = std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >; std::chrono::minutes = std::chrono::duration<long int, std::ratio<60> >]’
 8025 | from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,

/usr/include/c++/14/bits/chrono_io.h:2750:5: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::chrono::from_stream(std::basic_istream<_CharT, _Traits>&, const _CharT*, sys_time<_Duration>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*, minutes*) [with _CharT = char; _Traits = std::char_traits<char>; _Duration = duration<long int, std::ratio<1, 1000000000> >; _Alloc = std::allocator<char>; sys_time<_Duration> = time_point<_V2::system_clock, duration<long int, std::ratio<1, 1000000000> > >; minutes = duration<long int, std::ratio<60> >]’
 2750 |     from_stream(basic_istream<_CharT, _Traits>& __is, const _CharT* __fmt,
      |     ^~~~~~~~~~~

The issue has been introduced at f079e35
The patch is working on g++-11 and g++-14

@agmt agmt changed the title Fix build on GCC-14 Build fix for ambiguity with gcc >= 14 Feb 14, 2025
@HowardHinnant
Copy link
Copy Markdown
Owner

I encourage clients to use <chrono> in place of this library on this platform.

offa added a commit to offa/influxdb-cxx that referenced this pull request Mar 12, 2025
The date library is broken on GCC / Clang on this commit, thus PR866
(HowardHinnant/date#866) is applied.
offa added a commit to offa/influxdb-cxx that referenced this pull request Mar 12, 2025
The date library is broken on GCC / Clang on this commit, thus PR866
(HowardHinnant/date#866) is applied.
jktjkt added a commit to CESNET/libyang-cpp that referenced this pull request May 28, 2025
On GCC 14.2, this won't build for me:

 include/libyang-cpp/Time.hpp:117:34: error: no matching function for call to ‘parse(const char [21], std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >&)’

The error message is actually the same as in a proposed fix [1], and
upstream maintainer has said that they actually recommend relying on the
STL on this "new enough" platform. I'm very happy to oblige.

We were discussing this last year
(I51242fe2ec873fba5954c44e38e898d205a9e484), but at the time this was
implemented the build failure was not known, AFAICT, so let's assume
that the former use case for building with "new enough STL", but
actually forcing HH-date, is no longer important.

[1] HowardHinnant/date#866

Change-Id: Id4b0206e2a960686fb1d8e76134b9061d7545d81
Humblesaw pushed a commit to Humblesaw/libyang-cpp that referenced this pull request Nov 24, 2025
On GCC 14.2, this won't build for me:

 include/libyang-cpp/Time.hpp:117:34: error: no matching function for call to ‘parse(const char [21], std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >&)’

The error message is actually the same as in a proposed fix [1], and
upstream maintainer has said that they actually recommend relying on the
STL on this "new enough" platform. I'm very happy to oblige.

We were discussing this last year
(I51242fe2ec873fba5954c44e38e898d205a9e484), but at the time this was
implemented the build failure was not known, AFAICT, so let's assume
that the former use case for building with "new enough STL", but
actually forcing HH-date, is no longer important.

[1] HowardHinnant/date#866

Change-Id: Id4b0206e2a960686fb1d8e76134b9061d7545d81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants