[ET Trac] #2548: Compilation failure: "const" assignment in LoopControl/src/loopcontrol.cc

Roland Haas trac-noreply at einsteintoolkit.org
Fri Aug 6 17:36:55 CDT 2021


#2548: Compilation failure: "const" assignment in LoopControl/src/loopcontrol.cc

 Reporter: Bernard Kelly
   Status: open
Milestone: ET_2021_05
  Version: ET_2021_05
     Type: bug
 Priority: major
Component: EinsteinToolkit thorn

Comment (by Roland Haas):

I can compile fine with Intel 17 on Blue Waters if I use a modern enough C\+\+ library. However if I force it to use gcc 4.3 by using --gxx-name then I get the same error that you see:

```
COMPILING Carpet/LoopControl/src/loopcontrol.cc
/mnt/a/u/staff/rhaas/ET_Next/arrangements/Carpet/LoopControl/src/loopcontrol.cc(70): error: function call must have a constant value in a constant expression
      lc_random.max() - lc_random.min() + 1;
                ^

/mnt/a/u/staff/rhaas/ET_Next/arrangements/Carpet/LoopControl/src/loopcontrol.cc(70): error: function call must have a constant value in a constant expression
      lc_random.max() - lc_random.min() + 1;
                                  ^

compilation aborted for /mnt/a/u/staff/rhaas/ET_Next/configs/sim-intel/build/LoopControl/loopcontrol.cc (code 2)
```

so both this and #2547 are due to a too old stdc\+\+ library. Trying to work around this by using `minstd_rand::max()` does not work and gives:

```plaintext
COMPILING Carpet/LoopControl/src/loopcontrol.cc
/mnt/a/u/staff/rhaas/ET_Next/arrangements/Carpet/LoopControl/src/loopcontrol.cc(70): error: a nonstatic member reference must be relative to a specific object
      minstd_rand::max() - minstd_rand::min() + 1;
      ^

/mnt/a/u/staff/rhaas/ET_Next/arrangements/Carpet/LoopControl/src/loopcontrol.cc(70): error: a nonstatic member reference must be relative to a specific object
      minstd_rand::max() - minstd_rand::min() + 1;
                           ^

compilation aborted for /mnt/a/u/staff/rhaas/ET_Next/configs/sim-intel/build/LoopControl/loopcontrol.cc (code 2)
```

indicating that the library does not declare the function correctly as a static class function and indeed digging into the header files on BlueWaters shows it to be defined as:

```c++
      result_type
      max() const
      { return __m - 1; }
```

A workaround would be to remove `constexpr` from this line of code but given that thorn `Vectors` also fails with due to the same old C\+\+ library, I am not sure if the workaround would help a lot \(would only help in situations where `LoopControl` but not `Vectors` is used\).

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2548/compilation-failure-const-assignment-in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.einsteintoolkit.org/pipermail/trac/attachments/20210806/889b6db5/attachment-0001.html 


More information about the Trac mailing list