ns-3-dev build broken on Mac OSX

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ns-3-dev build broken on Mac OSX

Stefano Avallone
Hello,

commit "wifi: Make wifi-utils constexpr” breaks ns-3-dev build on my mac (Apple LLVM version 8.0.0 (clang-800.0.42.1)):

In file included from ../examples/wireless/simple-ht-hidden-stations.cc:23:
In file included from ./ns3/wifi-module.h:94:
./ns3/wifi-utils.h:35:18: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
constexpr double DbmToW (double dbm)
                 ^
./ns3/wifi-utils.h:37:10: note: non-constexpr function 'pow' cannot be used in a constant expression
  return std::pow (10.0, dbm / 10.0) / 1000.0;
         ^
/usr/include/math.h:443:15: note: declared here
extern double pow(double, double);
              ^
In file included from ../examples/wireless/simple-ht-hidden-stations.cc:23:
In file included from ./ns3/wifi-module.h:94:
./ns3/wifi-utils.h:47:18: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
constexpr double DbToRatio (double db)
                 ^
./ns3/wifi-utils.h:49:10: note: non-constexpr function 'pow' cannot be used in a constant expression
  return std::pow (10.0, db / 10.0);
         ^
/usr/include/math.h:443:15: note: declared here
extern double pow(double, double);
              ^
and so on…


The problem is that the functions of wifi-utils have been made constexpr but the functions of the math library (pow, log10) are not.

I am not sure how to workaround this issue. Ideas?

By the way, I am not sure what the goal of making these functions constexpr is. To my knowledge, constexpr provides a way to guarantee that an initialisation is done at compile time. Hence, is it even possible to make these functions constexpr, i.e., are we guaranteed that their arguments are always known at compile time?

Bests,
Stefano


Reply | Threaded
Open this post in threaded view
|

Re: ns-3-dev build broken on Mac OSX

Alexander Krotov-2
On Fri, Dec 30, 2016 at 04:04:47PM +0100, Stefano Avallone wrote:
> The problem is that the functions of wifi-utils have been made constexpr but the functions of the math library (pow, log10) are not.
>
> I am not sure how to workaround this issue. Ideas?

I just backed out this change.  It seems std::pow and other math functions
set errno so they are not constexpr. It should not work with gcc too,
probably it is a bug that it does not detect it.

I am currently trying to make patch series to unify propagation and
spectrum pathloss models so all existing propagation models can be used
with spectrum PHYs. This patch is just a byproduct.  Similar conversion
functions are used in wifi, lte and propagation modules, so I wanted
to move them to propagation module eventually.