astro-informatics / purify

Next-generation radio interferometric imaging.
https://astro-informatics.github.io/purify
GNU General Public License v2.0
17 stars 13 forks source link

Possible bug in clang on ubuntu #292

Closed tkoskela closed 1 year ago

tkoskela commented 2 years ago

Our clang builds on Github Actions with ubuntu-20.04 and clang 10, 11 and 12 fail with

/home/runner/work/purify/purify/build/external/include/sopt/relative_variation.h:44:11: error: no viable overloaded '='
    name_ = name;
    ~~~~~ ^ ~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.h:665:7: note: candidate function not viable: 'this' argument has type 'const std::string' (aka 'const basic_string<char>'), but method is not marked const
      operator=(const basic_string& __str)
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.h:675:7: note: candidate function not viable: 'this' argument has type 'const std::string' (aka 'const basic_string<char>'), but method is not marked const
      operator=(const _CharT* __s)
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.h:686:7: note: candidate function not viable: 'this' argument has type 'const std::string' (aka 'const basic_string<char>'), but method is not marked const
      operator=(_CharT __c)
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.h:703:7: note: candidate function not viable: 'this' argument has type 'const std::string' (aka 'const basic_string<char>'), but method is not marked const
      operator=(basic_string&& __str)
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.h:766:7: note: candidate function not viable: 'this' argument has type 'const std::string' (aka 'const basic_string<char>'), but method is not marked const
      operator=(initializer_list<_CharT> __l)
      ^

The include path /usr/include/c++/10 is the same that gcc uses but that seems correct, based on e.g. this stackoverflow thread and another stackoverflow thread

There's a thread reporting a bug in clang which may be related to ours

It's also worth noting that Apple clang-13 happily compiles this. The .travis.yaml file suggests thatclang-5 was previously used. Currently GitHub actions gives us clang-11 by default, with 10 and 12 also available. The same bug appears with them.