boost-ext / di

C++14 Dependency Injection Library
https://boost-ext.github.io/di
1.16k stars 140 forks source link

test.injections_named_parameters & example.annotations: Fail compilation on gcc 9+ #404

Closed jamespharvey20 closed 5 years ago

jamespharvey20 commented 5 years ago

Expected Behavior

test.injections_named_parameters and example.annotations should compile.

Actual Behavior

gcc 9 may be released as early as tomorrow. Using its current git build, or using the new gcc 10 git build, fails with this error:

[ 10%] Building CXX object extension/test/CMakeFiles/test.injections_named_parameters.dir/injections/named_parameters.cpp.o
cd /home/jamespharvey20/home/code/di.my.git/build/extension/test && /usr/bin/c++   -I/home/jamespharvey20/home/code/di.my.git/extension/test -I/home/jamespharvey20/home/code/di.my.git/include -I/
home/jamespharvey20/home/code/di.my.git/extension/include  -std=gnu++1y -fno-exceptions -pedantic -Wall -Wextra -Werror   -o CMakeFiles/test.injections_named_parameters.dir/injections
/named_parameters.cpp.o -c /home/jamespharvey20/home/code/di.my.git/extension/test/injections/named_parameters.cpp
In file included from /home/jamespharvey20/home/code/di.my.git/extension/test/injections/named_parameters.cpp:11:
/home/jamespharvey20/home/code/di.my.git/extension/include/boost/di/extension/injections/named_parameters.hpp:51:16: error: ISO C++ did not adopt string literal operator templates tak
ing an argument pack of characters [-Werror=pedantic]
   51 | constexpr auto operator""_s() {
      |                ^~~~~~~~
cc1plus: all warnings being treated as errors

(Same error for example/annotations.cpp:60:16.)

   60 | constexpr auto operator""_s() {
      |                ^~~~~~~~

Steps to Reproduce the Problem

  1. Install gcc 9+
  2. make test.injections_named_parameters or make example.annotations

Specifications

MrPointer commented 3 years ago

Hi, sorry for bringing up this old issue, but I'm having some trouble compiling code with the named_paramteres extension on gcc 9.3 due to this pedantic warning... You see, in my org, we treat warnings as errors, and we enable all warnings, passing -Wall -Werror to gcc (using CMake). AFAIU, the pragma referenced in the fix forces a pedantic warning on the string-literal block of code, and since we treat all warnings as errors, it makes the compiler error out, and this is NOT the desired behavior.

I played with it a bit and found out that if I replace the pragma's warning with ignored, it compiles, but that would force me to modify boost::di's source code and I don't want that (I'm getting it from Conan for multiple projects, can't change the source even if I wanted to).
@jamespharvey20 @krzysztof-jusiak Any ideas on how to handle that?

krzysztof-jusiak commented 3 years ago

@MrPointer, hmm, are you getting the same warning/error?

constexpr auto operator""_s() {

as before?

MrPointer commented 3 years ago

Yep, exactly that, along with a nice informative message on literals not being adopted by ISO C++ (don't have it in front of me now, replying from mobile). It's basically the same behavior as was before this "fix", it seems.