Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13191: undefined reference error when ODR-using boost::ratio::{num, den}
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-11-01 23:34:19
#13191: undefined reference error when ODR-using boost::ratio::{num,den}
-------------------------------+---------------------
Reporter: anonymous | Owner: viboes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: ratio
Version: Boost 1.59.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------
Comment (by anonymous):
Replying to [comment:2 yuri.goldfeld@â¦]:
> Ah, glad I'm not the only person experiencing this. gcc and clang C++03
mode => code was fine for years; clang C++11 mode => undefined reference
for ratio<>::num and ::den.
>
> Though, I am not totally sure what "ODR-using" is, exactly, nor how to
work around this. I'm sure I'll find a way, but this seems like a rather
significant link error given the simplicity and thus probable commonness
of what is being attempted here. It doesn't seem like the repro (nor my
code, not provided here) is doing anything strange.
For the record, *a* work-around I found is to indeed define what appears
to be under #ifdef in the ratio.hpp code. Like so, in your .cc or .cpp
file:
template <boost::intmax_t N, boost::intmax_t D>
const boost::intmax_t boost::ratio<N, D>::num;
template <boost::intmax_t N, boost::intmax_t D>
const boost::intmax_t boost::ratio<N, D>::den;
That should do it as a work-around. However, presumably it'll break if the
compiler lacks constexpr, as it would be a duplicate or something along
those lines.
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13191#comment:3> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-11-01 23:39:56 UTC