Summary: | compile error when trying to use pointer-to-member function as invokable projection to ranges::find() | ||
---|---|---|---|
Product: | gcc | Reporter: | Daniel Boles <dboles.src> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | normal | CC: | daniel.kruegler, jason, webrown.cpp |
Priority: | P3 | Keywords: | rejects-valid |
Version: | 9.3.0 | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94771 | ||
Host: | Target: | *-*-mingw* | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2020-05-06 00:00:00 | |
Bug Depends on: | |||
Bug Blocks: | 101603 | ||
Attachments: | test.ii from --save-temps |
Description
Daniel Boles
2020-05-06 15:03:46 UTC
Please read https://gcc.gnu.org/bugs and provide the missing information. Why is this marked as a libstdc++ bug? I can't reproduce this using range-v3 0.10.0 and GCC 9.3.0 on GNU/Linux, the example compiles fine. > Please read https://gcc.gnu.org/bugs and provide the missing information. Fair point. Let me know if I missed anything still. the exact version of GCC; g++.exe (Rev2, Built by MSYS2 project) 9.3.0 the system type; Windows, g++ provided by MSYS2/MinGW64 projects the options given when GCC was configured/built; I didn't build it. Is there a switch that can get this for you? the complete command line that triggers the bug; g++ -I /home/ME/.local/include/range-v3 -std=c++17 -Wall -Wextra -Wpedantic test.cpp the compiler output (error messages, warnings, etc.); already included. the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command I will attach this next. > Why is this marked as a libstdc++ bug? I chose libstdc++ because I figured it was more likely that some corner case of std::invoke() was ultimately being hit, rather than the core compiler being at fault. I guess not. > I can't reproduce this using range-v3 0.10.0 and GCC 9.3.0 on GNU/Linux, the example compiles fine. Curioser and curioser. It's fine on clang++ on Windows too. Seems a corner case. Created attachment 48470 [details]
test.ii from --save-temps
I can reproduce it using x86_64-w64-mingw32-g++ 9.2.1 Reduced: #include <range/v3/algorithm/find.hpp> struct X { int get_i() const { return 0; } }; static_assert( ranges::indirectly_regular_unary_invocable<int (X::*)() const, X*> ); Th static assert fails with mingw but not with a native compiler on linux. I'm not yet convinced this isn't a ranges-v3 bug. (In reply to DB from comment #3) > I didn't build it. Is there a switch that can get this for you? As it says on that page, "the first three of which can be obtained from the output of gcc -v" But I can reproduce it now anyway. Further reduced: #include <range/v3/algorithm/find.hpp> struct X { }; using F = int (X::*)() const; using I = X*; using R1 = ranges::invoke_result_t<F&, X&>; static_assert( std::is_same_v<R1, int> ); This fails because R1 is int (X::)() const which is nonsense. (In reply to DB from comment #3) > I chose libstdc++ because I figured it was more likely that some corner case > of std::invoke() was ultimately being hit, rather than the core compiler > being at fault. I guess not. std::invoke is not even used, ranges-v3 provides its own invoke. > I can reproduce it using x86_64-w64-mingw32-g++ 9.2.1 Thanks again for testing! > I'm not yet convinced this isn't a ranges-v3 bug. I will of course defer to your expertise! It could well be caused by something buried somewhere in range-v3's many layers of supporting code. If it can't be a g++ bug, of course just say the word, and I will just forward this all to them. > As it says on that page, "the first three of which can be obtained from the output of gcc -v" D'oh. Here we are: $ g++ -v Using built-in specs. COLLECT_GCC=C:\msys64\mingw64\bin\g++.exe COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.3.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-9.3.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld Thread model: posix gcc version 9.3.0 (Rev2, Built by MSYS2 project) If it used std::invoke it would compile: static_assert( std::is_same_v<std::invoke_result_t<F&, X&>, int> ); // OK static_assert( std::is_same_v<ranges::invoke_result_t<F&, X&>, int> ); // ERROR Aha, the same problem happens on linux if I compile with -fms-extensions This is the old MS extension that causes x.*f to be accepted when f is a pointer to member function, which should only be valid when used as (x.*f)(). That causes ranges::invoke to think that the projection is a pointer to data member, when actually it's a pointer to member function. See also PR 94771 comment 4. Jason, do we want to disable that extension in SFINAE contexts? Oops, CCing Jason this time. -fno-ms-extensions will allow you to compile it, as long as you aren't relying on any of the other MSVC compatibility quirks. Does MSVC still accept that [without diagnostic]? Maybe it's time to remove it completely... No (see PR 94771 comment 4) Aha, many thanks for the findings. IMO the MS extensions should really be off by default, esp if compiling in a Standard mode, until the user actually says they want them... right? They seem liable to lead to issues. And might explain lots of other weird warning spam I got earlier... (All I do special is pass -mwindows, just to avoid a spurious terminal) > -fno-ms-extensions will allow you to compile it, as long as you aren't relying on any of the other MSVC compatibility quirks.
That indeed fixes the problem, as well as squashing lots of other spurious warnings (some of which default to errors!) from libsigc++ in the same project that were Windows-specific. Thanks!
They're on by default for mingw, for compatibility with the MS compiler (but in this case it seems the relevant extension is ancient history). |