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

DEBUG_ASSERT_PURE_FUNCTION broken with GCC9 #17

Closed
raitraak-rrk opened this issue May 18, 2019 · 8 comments
Closed

DEBUG_ASSERT_PURE_FUNCTION broken with GCC9 #17

raitraak-rrk opened this issue May 18, 2019 · 8 comments

Comments

@raitraak-rrk
Copy link

First of all, thanks for the library!

GCC9 seems to break something with the pure attribute definition. Couldn't figure out what's the issue there. Temporary workaround is to define "DEBUG_ASSERT_PURE_FUNCTION=".

build.log

@NikolausDemmel
Copy link

For the same reason type_safe fails to compile for me with gcc9. Adding -DDEBUG_ASSERT_PURE_FUNCTION= works as a workaround for me as well.

$ CXX=$HOME/.linuxbrew/opt/gcc@9/bin/g++-9 CC=$HOME/.linuxbrew/opt/gcc@9/bin/gcc-9 cmake ..
-- The C compiler identification is GNU 9.1.0
-- The CXX compiler identification is GNU 9.1.0
-- Check for working C compiler: /usr/wiss/demmeln/.linuxbrew/opt/gcc@9/bin/gcc-9
-- Check for working C compiler: /usr/wiss/demmeln/.linuxbrew/opt/gcc@9/bin/gcc-9 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/wiss/demmeln/.linuxbrew/opt/gcc@9/bin/g++-9
-- Check for working CXX compiler: /usr/wiss/demmeln/.linuxbrew/opt/gcc@9/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Installing debug_assert via submodule
Submodule 'external/debug_assert' (https://github.com/foonathan/debug_assert) registered for path 'external/debug_assert'
Cloning into 'external/debug_assert'...
Submodule path 'external/debug_assert': checked out '0144b6532ec80349780ffac3cf85a92d87eb7b1b'
-- Configuring done
-- Generating done
-- Build files have been written to: /storage/slurm/demmeln/dba/dbatk/foo/type_safe/build
$ make
Scanning dependencies of target type_safe_example_constrained
[  2%] Building CXX object example/CMakeFiles/type_safe_example_constrained.dir/constrained.cpp.o
In file included from /storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/detail/assert.hpp:8,
                 from /storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp:14,
                 from /storage/slurm/demmeln/dba/dbatk/foo/type_safe/example/constrained.cpp:8:
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp: In lambda function:
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp:335:72: error: expected ‘{’ before ‘noexcept’
  335 |                                             DEBUG_ASSERT_PURE_FUNCTION noexcept { return Expr; },  \
      |                                                                        ^~~~~~~~
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp:397:9: note: in expansion of macro ‘DEBUG_ASSERT’
  397 |         DEBUG_ASSERT(value_, detail::precondition_error_handler{});
      |         ^~~~~~~~~~~~
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp: In member function ‘type_safe::constrained_modifier<T, Constraint, Verifier>::value_type& type_safe::constrained_modifier<T, Constraint, Verifier>::get()’:
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp:335:72: error: expected ‘)’ before ‘noexcept’
  335 |                                             DEBUG_ASSERT_PURE_FUNCTION noexcept { return Expr; },  \
      |                                                                        ^~~~~~~~
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp:397:9: note: in expansion of macro ‘DEBUG_ASSERT’
  397 |         DEBUG_ASSERT(value_, detail::precondition_error_handler{});
      |         ^~~~~~~~~~~~
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp:334:40: note: to match this ‘(’
  334 |         debug_assert::detail::do_assert([&]()                                                      \
      |                                        ^
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp:397:9: note: in expansion of macro ‘DEBUG_ASSERT’
  397 |         DEBUG_ASSERT(value_, detail::precondition_error_handler{});
      |         ^~~~~~~~~~~~
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp: In instantiation of ‘constexpr typename debug_assert::detail::enable_if<(Handler::level != 0), debug_assert::detail::regular_void>::type debug_assert::detail::do_assert(const Expr&, const debug_assert::source_location&, const char*, Handler, Args&& ...) [with Expr = type_safe::constrained_modifier<T, Constraint, Verifier>::get() [with T = std::__cxx11::basic_string<char>; Constraint = type_safe::constraints::non_empty; Verifier = type_safe::assertion_verifier; type_safe::constrained_modifier<T, Constraint, Verifier>::value_type = std::__cxx11::basic_string<char>]::<lambda()>; Handler = type_safe::detail::precondition_error_handler; Args = {}; typename debug_assert::detail::enable_if<(Handler::level != 0), debug_assert::detail::regular_void>::type = debug_assert::detail::regular_void]’:
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/include/type_safe/constrained_type.hpp:397:9:   required from ‘type_safe::constrained_modifier<T, Constraint, Verifier>::value_type& type_safe::constrained_modifier<T, Constraint, Verifier>::get() [with T = std::__cxx11::basic_string<char>; Constraint = type_safe::constraints::non_empty; Verifier = type_safe::assertion_verifier; type_safe::constrained_modifier<T, Constraint, Verifier>::value_type = std::__cxx11::basic_string<char>]’
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/example/constrained.cpp:25:22:   required from here
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp:283:24: error: could not convert ‘(& expr)->type_safe::constrained_modifier<T, Constraint, Verifier>::get() [with T = std::__cxx11::basic_string<char>; Constraint = type_safe::constraints::non_empty; Verifier = type_safe::assertion_verifier; type_safe::constrained_modifier<T, Constraint, Verifier>::value_type = std::__cxx11::basic_string<char>]::<lambda()>()’ from ‘void’ to ‘bool’
  283 |             return expr() ? regular_void() :
      |                    ~~~~^~
      |                        |
      |                        void
/storage/slurm/demmeln/dba/dbatk/foo/type_safe/external/debug_assert/debug_assert.hpp:286:9: error: body of ‘constexpr’ function ‘constexpr typename debug_assert::detail::enable_if<(Handler::level != 0), debug_assert::detail::regular_void>::type debug_assert::detail::do_assert(const Expr&, const debug_assert::source_location&, const char*, Handler, Args&& ...) [with Expr = type_safe::constrained_modifier<T, Constraint, Verifier>::get() [with T = std::__cxx11::basic_string<char>; Constraint = type_safe::constraints::non_empty; Verifier = type_safe::assertion_verifier; type_safe::constrained_modifier<T, Constraint, Verifier>::value_type = std::__cxx11::basic_string<char>]::<lambda()>; Handler = type_safe::detail::precondition_error_handler; Args = {}; typename debug_assert::detail::enable_if<(Handler::level != 0), debug_assert::detail::regular_void>::type = debug_assert::detail::regular_void]’ not a return-statement
  286 |         }
      |         ^
example/CMakeFiles/type_safe_example_constrained.dir/build.make:62: recipe for target 'example/CMakeFiles/type_safe_example_constrained.dir/constrained.cpp.o' failed
make[2]: *** [example/CMakeFiles/type_safe_example_constrained.dir/constrained.cpp.o] Error 1
CMakeFiles/Makefile2:116: recipe for target 'example/CMakeFiles/type_safe_example_constrained.dir/all' failed
make[1]: *** [example/CMakeFiles/type_safe_example_constrained.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

@foonathan
Copy link
Owner

Yeah, it's the same issue.

I don't have access to GCC 9, so can't fix it right now. Anyone willing to do a PR changing the macro definition from __attribute__(pure) to [[gnu::pure]] and see if that fixes it?

@raitraak-rrk
Copy link
Author

Doesn't help.
https://godbolt.org/z/TheeeA

Says the attribute is ignored, but I cannot understand the message:
note: an attribute that appertains to a type-specifier is ignored.

@foonathan
Copy link
Owner

Oh, right, I can use godbolt. I will figure something out.

@raitraak-rrk
Copy link
Author

Thanks mate. No rush though. Workaround is good for now.

@foonathan
Copy link
Owner

I've just decided to remove the macro.

@NikolausDemmel
Copy link

NikolausDemmel commented Jun 17, 2019

Wait, I just tested this and I'm still getting the same errors for type_safe with gcc 9 on Ubuntu 16.04:

type_safe/build (detached*)$ CXX=~/.linuxbrew/bin/g++-9 CC=~/.linuxbrew/bin/gcc-9 cmake ..
-- The C compiler identification is GNU 9.1.0
-- The CXX compiler identification is GNU 9.1.0
-- Check for working C compiler: /usr/wiss/demmeln/.linuxbrew/bin/gcc-9
-- Check for working C compiler: /usr/wiss/demmeln/.linuxbrew/bin/gcc-9 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/wiss/demmeln/.linuxbrew/bin/g++-9
-- Check for working CXX compiler: /usr/wiss/demmeln/.linuxbrew/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Installing debug_assert via submodule
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/build
type_safe/build (detached*)$ make
Scanning dependencies of target type_safe_example_optional
[  2%] Building CXX object example/CMakeFiles/type_safe_example_optional.dir/optional.cpp.o
In file included from /usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/detail/assert.hpp:8,
                 from /usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/optional.hpp:12,
                 from /usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/example/optional.cpp:9:
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/optional.hpp: In lambda function:
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/external/debug_assert/debug_assert.hpp:335:72: error: expected ‘{’ before ‘noexcept’
  335 |                                             DEBUG_ASSERT_PURE_FUNCTION noexcept { return Expr; },  \
      |                                                                        ^~~~~~~~
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/optional.hpp:420:9: note: in expansion of macro ‘DEBUG_ASSERT’
  420 |         DEBUG_ASSERT(has_value(), detail::precondition_error_handler{});
      |         ^~~~~~~~~~~~
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/optional.hpp: In member function ‘decltype (declval<type_safe::basic_optional<StoragePolicy>::storage&>().get_value()) type_safe::basic_optional<StoragePolicy>::value() &’:
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/external/debug_assert/debug_assert.hpp:335:72: error: expected ‘)’ before ‘noexcept’
  335 |                                             DEBUG_ASSERT_PURE_FUNCTION noexcept { return Expr; },  \
      |                                                                        ^~~~~~~~
/usr/wiss/demmeln/slurm/dba/dbatk/external/type_safe/include/type_safe/optional.hpp:420:9: note: in expansion of macro ‘DEBUG_ASSERT’

[...]

PS: Curiously, it compiles fine with gcc 9 on macOS

@NikolausDemmel
Copy link

Sorry for the noise, somehow my submodules were messed up, such that git showed the new version was checked out, but the file was actually still the old one... Reinitializing the submodules fixed it.

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

3 participants