Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fix for ambiguity with gcc >= 14 #866

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agmt
Copy link

@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
Owner

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

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