Issues compiling with gcc7.3 with c++17

Create issue
Issue #2315 resolved
tootle created an issue

I’m currently in the process of installing Carpet via the latest repo of WhiskyTHC. See attached thornlist for details of versions.

During installation with gcc7.3 with -std=c++17, I continue to receive “error: reference to ‘data’ is ambiguous” related to the implementation of using overlapping namespaces with std (see attached make_thc.err for details).

I have obtained the same errors using Intel 2019. If I use Intel 2017, this error does not occur.

I came across issue 1121 which seemed similar in nature, but this was a much older compiler and I did not find a solution (compiler flag or the like) that would resolve the issue I was seeing. Additionally, I have attached the config file I am using which details compiler flags, declared variables etc.

Thank you for the assistance

Comments (10)

  1. Roland Haas

    I tried reproducing this using the master branch of Carpet with the compilers available on my workstation:

    • g++-9 (Debian 9.2.1-22) 9.2.1 20200104 compiles without error
    • g++-8 (Debian 8.3.0-26) 8.3.0 compiles without error
    • g++-7 (Debian 7.5.0-3) 7.5.0 compiles without error

    Switching to ET_2016_11 I find that:

    • g++-7 (Debian 7.5.0-3) 7.5.0 fails with the error your describe
    • g++-8 (Debian 8.3.0-26) 8.3.0 fails with the error your describe
    • g++-9 (Debian 9.2.1-22) 9.2.1 20200104 fails with the error your describe

    Since the version you are using (ET_2016_11) is 3 years old, there have been quite a few changes since then. However if I had to bet I’d say that git hash 986b01b2 "Move CarpetLib types and functions into a new namespace CarpetLib" of carpet is the one that makes it work in master.

    @{5b59c8ffe288ee2d9b4ba7ba} , you have some options:

    1. switch to use master (at least for Carpet)
    2. ask @David Radice whether a newer version of the ET can be used (anything starting with ET_2019_03 will do) with THC
    3. try and cherry pick the commit I pointed out and hope for the best

    Since this is a very old release we (the ET maintainers) are unlikely to backport a fix to it.

  2. David Radice

    I am not aware of any reason why THC should not work with a newer version of the ET: it should be only a matter of adding the thorns to the the standard ET thornlist. However, we have not tested it.

  3. tootle reporter

    @Roland Haas thank you for your response. I have attached the files related to starting from a clean directory and pulling all files related to ETK_19_10, but with Carpet repo set to master. However, I still obtain errors related to the Carpet “data” type.

  4. Roland Haas

    I get the same errors as you (gcc 7.5 as above) when compiling CarpetIOASCII. Before I had only compiled CarpetLib which compiles fine and thus I had not notice this, sorry. The error goes away when changing -std=gnu++17 to -std=gnu++11.

    Indeed a fix is to prefix the *(data<T>*)foo casts by CarpetLib:: to indicate the explicit namespace since the compiler cannot deduce the template based on function arguments.

    This pull request implements the required changes, though there may be better ways to solve this:

    With these changes I can compile your thornlist using std=gnu++17 and gcc-7.5.

  5. tootle reporter

    Reviewed and can confirm the work-around proposed resolves the compile issues using gcc-7.3 with -std=gnu++17 after correcting intel linking parameters in the previously attached cfg file.

    Thank you, @Roland Haas

  6. Log in to comment