Bug 92969 - Segmentation fault compiling partial specialization of auto-deduced member function pointers
Summary: Segmentation fault compiling partial specialization of auto-deduced member fu...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: pmf, ptmf
  Show dependency treegraph
 
Reported: 2019-12-17 09:05 UTC by Joe Antoon
Modified: 2024-01-22 17:10 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-07-23 00:00:00


Attachments
preprocessed source (256 bytes, text/plain)
2019-12-17 09:05 UTC, Joe Antoon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Antoon 2019-12-17 09:05:27 UTC
Created attachment 47511 [details]
preprocessed source

The following code, which auto-deduces and partially specializes a parameter pack of member function pointers, causes a segmentation fault during compilation:

CODE:
template <auto... Methods>
struct Foo;

template <
    typename Class,
    typename... ReturnType, 
    ReturnType (Class::*...Methods)()>
struct Foo<Methods...> {
    constexpr void operator ()() { }
};

struct Bar {
  int baz() { return 42; }
};

void tryOut() {
  Foo<&Bar::baz>{}();
}

EXPECTED RESULT: compiles on clang v9 without errors
ACTUAL RESULT:
during RTL pass: expand
<source>: In function 'void tryOut()':
<source>:17:19: internal compiler error: Segmentation fault
   17 |   Foo<&Bar::baz>{}();
      |   ~~~~~~~~~~~~~~~~^~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

Encountered on g++-9 Ubuntu 18.04 WSL.
COMMAND: g++ test.cpp -std=c++17
SYSTEM TYPE: x86_64-linux-gnu
VERSION: gcc version 9.2.1 20191102 (Ubuntu 9.2.1-17ubuntu1~18.04.1)
CONFIGURATION: Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-17ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Also reproduces on Compiler Explorer:
COMMAND: g++ test.cpp -std=c++17
SYSTEM TYPE: x86_64-linux-gnu
VERSION: gcc version 9.2.0 (Compiler-Explorer-Build) 
CONFIGURATION: Configured with: ../gcc-9.2.0/configure --prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap --enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran,ada,d --enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto --enable-plugins --enable-threads=posix --with-pkgversion=Compiler-Explorer-Build

https://godbolt.org/z/PJZdPL
Comment 1 Andrew Pinski 2021-07-23 19:23:41 UTC
Maybe related to PR 84287.