Closed tbreslein closed 2 years ago
Hi,
and thanks for the very detailed report. :+1:
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:
In file included from FunctionalPlus/include/fplus/fplus.hpp:11,
from main.cpp:1:
FunctionalPlus/include/fplus/container_common.hpp:154:42: error: expected unqualified-id before 'const'
154 | array_back_insert_iterator<T, N>(const array_back_insert_iterator<T, N>& other) :
| ^~~~~
FunctionalPlus/include/fplus/container_common.hpp:154:42: error: expected ')' before 'const'
154 | array_back_insert_iterator<T, N>(const array_back_insert_iterator<T, N>& other) :
| ~^~~~~
| )
I'm now testing your suggested fix on a branch. The CI will automatically test it for a whole bunch of different compiler versions. :slightly_smiling_face:
Just released the new version v0.2.17-p0
that includes your fix. :heavy_check_mark:
Thanks again for the good investigation and suggestion. :+1:
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-gcc11The 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!