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

Compiler diagnostic with clang from the LLVM 9 download package #80

Closed
johngladp opened this issue Jun 5, 2020 · 2 comments
Closed

Comments

@johngladp
Copy link

clang generates the following diagnostic fault when compiling using this library:

C:\Src\NetworkedGraphics\out\packages\argparse-src\package\include\argparse\argparse.hpp(196,28): error G3F63BFAE: constexpr variable 'generic_strtod' must be initialized by a constant expression [clang-diagnostic-error]
template <> constexpr auto generic_strtod = strtof;
^
C:\Src\NetworkedGraphics\out\packages\argparse-src\package\include\argparse\argparse.hpp(197,28): error G3F63BFAE: constexpr variable 'generic_strtod' must be initialized by a constant expression [clang-diagnostic-error]
template <> constexpr auto generic_strtod = strtod;
^
C:\Src\NetworkedGraphics\out\packages\argparse-src\package\include\argparse\argparse.hpp(198,28): error G3F63BFAE: constexpr variable 'generic_strtod' must be initialized by a constant expression [clang-diagnostic-error]
template <> constexpr auto generic_strtod = strtold;
^

The quick fix appears to be to remove the indicated constexpr qualifier.

This was picked up running an msvc compile (vs 16.6.0) followed by a clang-tidy run (llvm 9.0). The diagnostic is produced by clang within clang-tidy. clang-tidy is being run with msvc build commands from the configured cmake build database (standard usage).

@haozhangphd
Copy link

These three lines of code will give error on clang 11. Removing constexpr fixes the error.

@p-ranav
Copy link
Owner

p-ranav commented Sep 21, 2022

The latest version of the library has fixed this issue.

The build is clean, without warnings, and the tests pass.

pranav@ubuntu:~/dev/argparse/build$ export CC=/usr/bin/clang-12
pranav@ubuntu:~/dev/argparse/build$ export CXX=/usr/bin/clang++-12
pranav@ubuntu:~/dev/argparse/build$ cmake -DARGPARSE_BUILD_TESTS=on ..
-- The CXX compiler identification is Clang 12.0.0
-- Check for working CXX compiler: /usr/bin/clang++-12
-- Check for working CXX compiler: /usr/bin/clang++-12 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is Clang 12.0.0
-- Check for working C compiler: /usr/bin/clang-12
-- Check for working C compiler: /usr/bin/clang-12 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pranav/dev/argparse/build
pranav@ubuntu:~/dev/argparse/build$ make -j20
Scanning dependencies of target ARGPARSE
[  3%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_const_correct.cpp.o
[ 11%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_append.cpp.o
[ 14%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_actions.cpp.o
[ 18%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_compound_arguments.cpp.o
[ 22%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_default_args.cpp.o
[ 25%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_container_arguments.cpp.o
[ 29%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_get.cpp.o
[ 29%] Building CXX object test/CMakeFiles/ARGPARSE.dir/main.cpp.o
[ 37%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_help.cpp.o
[ 40%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_invalid_arguments.cpp.o
[ 40%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_equals_form.cpp.o
[ 44%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_is_used.cpp.o
[ 48%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_issue_37.cpp.o
[ 51%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_negative_numbers.cpp.o
[ 55%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_parent_parsers.cpp.o
[ 59%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_parse_args.cpp.o
[ 62%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_optional_arguments.cpp.o
[ 66%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_prefix_chars.cpp.o
[ 70%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_parse_known_args.cpp.o
[ 74%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_positional_arguments.cpp.o
[ 77%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_repr.cpp.o
[ 81%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_required_arguments.cpp.o
[ 85%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_scan.cpp.o
[ 88%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_subparsers.cpp.o
[ 92%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_value_semantics.cpp.o
[ 96%] Building CXX object test/CMakeFiles/ARGPARSE.dir/test_version.cpp.o
[100%] Linking CXX executable tests
[100%] Built target ARGPARSE
pranav@ubuntu:~/dev/argparse/build$ ./test/tests 
[doctest] doctest version is "2.4.8"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases: 158 | 158 passed | 0 failed | 1 skipped
[doctest] assertions: 706 | 706 passed | 0 failed |
[doctest] Status: SUCCESS!

@p-ranav p-ranav closed this as completed Sep 21, 2022
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