-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Cannot compile with gcc 11.2 in C++20 mode #251
Comments
Hi, and thanks for the very detailed report. 👍 I can reproduce the problem with the following minimal Dockerfile (g++ 11.2 with C++20): FROM gcc:11.2
RUN git clone -b 'v0.2.16-p0' --single-branch --depth 1 https://github.com/Dobiasd/FunctionalPlus
RUN echo '#include <fplus/fplus.hpp>' > main.cpp
RUN echo 'int main() {}' >> main.cpp
RUN g++ -I FunctionalPlus/include -std=c++14 main.cpp
RUN g++ -I FunctionalPlus/include -std=c++17 main.cpp
RUN g++ -I FunctionalPlus/include -std=c++20 main.cpp Output of the last line:
I'm now testing your suggested fix on a branch. The CI will automatically test it for a whole bunch of different compiler versions. 🙂 |
Just released the new version Thanks again for the good investigation and suggestion. 👍 |
Cool, you're welcome and thank you for implementing it! |
Hi,
I just found a weird "bug" that makes it so you cannot compile fplus (0.2.16) with gcc 11.2 in C++20 mode (maybe earlier compiler version work flawlessly, cannot test that right now unfortunately). It works perfectly fine with other C++ standards, and it works with clang (13.0). I have sorta "fixed" the issue though on my end, and that fix works with those two compilers on all standards 14-20.
Here's my CMake file (sorry for the noise with conan):
And I'm just configuring with:
Here's the source file for my little example (which is just examples from your README copy pasted lol):
When compiling with the aforementioned compiler and standard combination (
gcc 11.2
in C++20 mode), I'm receiving this error:A little google search reveals that the error is is the
<T,N>
template parameters attached to the function, and that this is supposedly considered a bug in 'older' compiler versions:https://stackoverflow.com/questions/67698523/error-in-llvm-stlextras-expected-unqualified-id-before-const-with-gcc11
The fix is simple enough, just remove those parameters, so that the constructor in question (
container_common.hpp:154
in release 0.2.16) reads as:instead of
The templated types can still be deduced by the type of input parameter
other
, so this "should just work".I "fixed" this in my local clone of the library, and tested it with
gcc 11.2
andclang 13.0
in the standards 14, 17, and 20. They all compile and run my little example fine now.Similarly, I cannot compile your doctests when configuring them with
-DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_STANDARD=20
(though, after the fix, I run into the same problem as issue #250 during linking; it does compile the object files successfully so the error I encountered seems entirely gone, I guess?)So, is there any concern with this little fix? Unfortunately, I currently cannot test this with the other compiler versions you are supporting myself, and won't be able to test it with Visual Studio and XCode at all.
It's a bit of a wall of text, sorry, but I guess it's probably fairly detailed too ^^'
Cheers!
The text was updated successfully, but these errors were encountered: