Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build with clang++-6.0 #17

Closed
nolange opened this issue May 22, 2018 · 5 comments
Closed

Does not build with clang++-6.0 #17

nolange opened this issue May 22, 2018 · 5 comments

Comments

@nolange
Copy link

nolange commented May 22, 2018

Hello, the tests won't build with clang-6.0, problem is the C++17 configuration in combination with a C++ Library that provides std::byte.
First the issue:

[ 33%] Building CXX object test/CMakeFiles/span-main-cpp17.t.dir/span.t.cpp.o
In file included from /home/lano/git/span-lite/test/span.t.cpp:11:
In file included from /home/lano/git/span-lite/test/span-main.t.hpp:14:
/home/lano/git/span-lite/test/lest_cpp03.hpp:648:53: error: call to function
      'operator<<' that is neither visible in the template definition nor found
      by argument-dependent lookup
        std::ostringstream os; os << std::boolalpha << value;
                                                    ^
/home/lano/git/span-lite/test/lest_cpp03.hpp:674:29: note: in instantiation of
      member function 'lest::string_maker<std::byte>::to_string' requested here
    return string_maker<T>::to_string( value );
                            ^
/home/lano/git/span-lite/test/lest_cpp03.hpp:715:34: note: in instantiation of
      function template specialization 'lest::to_string<std::byte>' requested
      here
    std::ostringstream os; os << to_string( lhs ) << " " << op << " " <...
                                 ^
/home/lano/git/span-lite/test/lest_cpp03.hpp:727:92: note: in instantiation of
      function template specialization 'lest::to_string<std::byte, std::byte>'
      requested here
  ...operator==( R const & rhs ) { return result( lhs == rhs, to_string( lhs...
                                                              ^
/home/lano/git/span-lite/test/span.t.cpp:992:19: note: in instantiation of
      function template specialization 'lest::expression_lhs<const std::byte
      &>::operator==<std::byte>' requested here
    EXPECT( vb[0] == b[0] );
                  ^
/home/lano/git/span-lite/test/lest_cpp03.hpp:229:28: note: expanded from macro
      'EXPECT'
# define EXPECT            lest_EXPECT
                           ^
/home/lano/git/span-lite/test/span-main.t.hpp:40:23: note: 'operator<<' should
      be declared prior to the call site
inline std::ostream & operator<<( std::ostream & os, std::byte b )

I used these flags for configuring, clang is version 6.0, libstdc++ is version 7.3.0.
cmake -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_COMPILER=clang++-6.0 -DCMAKE_C_COMPILER=clang-6.0..

Same issue persists if I tell clang to use libc++, which might be a useful additional configuration for the automated tests?
I generally tend to use IPO for testing as this might cause additional warnings or errors, roughly thats what I had to do:

apt-get install clang++-6.0 libc++abi-dev libc++-dev
cmake -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_COMPILER=clang++-6.0 -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_FLAGS=-stdlib=libc++ ..
@nolange
Copy link
Author

nolange commented May 22, 2018

Ok, since you allow failures for clang, I suppose that's not news for you ;)

@martinmoene
Copy link
Owner

Understanding it is a different matter.

@nolange
Copy link
Author

nolange commented May 22, 2018

Not sure I know what you are asking.

  • the error is not dependend on IPO, reproduces on clang without.
  • IPO removes the object boundaries for optimization and static analysis. under clang/gcc this is known as LTO/Link time Optimization
  • it might display errors that you would not otherwise detect, and might cause issues that arent appearing without (these are still programming errors)
  • CMake made the decision to disable/disallow IPO for projects written for CMake Version < 3.9. I dont agree with this, but you have to either depend on CMake >= 3.9 or switch the policy to enable IPO on projects. This was done in the hope of preventing software to unexpectedly blow up with changed compiler-switches, probably saved 1 person in the whole wide world some time while annoying everyone else.

short: enabling IPO detects stuff like ODR violations across source-files, and if your software tests fine with IPO enabled then it will test fine without - the other way around is not guaranteed.

@martinmoene
Copy link
Owner

Thanks for your explanation. It was a note that I don't understand the source of the compilation error (yet) and a link (for myself) to read up on CMake's policy CMP0069 and IPO. (I could have written something less confusing indeed.)

@nolange
Copy link
Author

nolange commented May 22, 2018

you need to declare inline std::ostream & operator<<( std::ostream & os, std::byte b ) (test/span-main.t.hpp:40:23)

before accessing it in template< typename T > struct string_maker::to_string (test/lest_cpp03.hpp:648:53)

right now its defined afterwards, you need to at least declare a prototype before using it within template< typename T > struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants