https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107584

--- Comment #1 from Viktor Shepel <viktor.shepel.public at gmail dot com> ---
Hi
Required items are below.

#1. exact version of GCC
7.5.0

#2. system type
$lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

#3. options given when GCC was configured/built
$g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--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-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --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 --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 

#4. complete command line that triggers the bug
g++ -std=c++17 issue.cpp

#5. compiler output
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/nested_exception.h:40,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from issue.cpp:1:
/usr/include/c++/7/type_traits: In instantiation of ‘struct
std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
formatted_input_t, std::vector<int, std::allocator<int> > >’:
/usr/include/c++/7/experimental/type_traits:242:71:   required by substitution
of ‘template<template<class ...> class _Op, class ... _Args> using is_detected
= typename std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
_Op, _Args ...>::value_t [with _Op = formatted_input_t; _Args =
{std::vector<int, std::allocator<int> >}]’
issue.cpp:12:16:   required from ‘constexpr const bool
is_ostreamable_v<std::vector<int> >’
issue.cpp:30:5:   required from here
/usr/include/c++/7/type_traits:2512:5: internal compiler error: in
finish_member_declaration, at cp/semantics.c:3023
     {
     ^

#6. preprocessed file
file `issue.ii` in attachment



Additional info:

#1. Versions 8.4.0, 9.4.0, 10.3.0 and 11.1.0 produce error rather crash
In file included from issue.cpp:4:
/usr/include/c++/11/experimental/type_traits: In substitution of
‘template<template<class ...> class _Op, class ... _Args> using is_detected =
typename std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
_Op, _Args ...>::value_t [with _Op = formatted_input_t; _Args =
{std::vector<int, std::allocator<int> >}]’:
issue.cpp:19:66:   required from ‘constexpr bool is_ostreamable() [with T =
std::vector<int>]’
issue.cpp:24:39:   required by substitution of ‘template<class T, typename
std::enable_if<is_ostreamable<T>(), bool>::type <anonymous> > std::ostream&
operator<<(std::ostream&, const T&) [with T = std::vector<int>; typename
std::enable_if<is_ostreamable<T>(), bool>::type <anonymous> = <missing>]’
/usr/include/c++/11/experimental/type_traits:245:9:   recursively required by
substitution of ‘template<class _Default, template<class ...> class _Op, class
... _Args> struct std::__detector<_Default, std::__void_t<_Op<_Args ...> >,
_Op, _Args ...> [with _Default = std::experimental::fundamentals_v2::nonesuch;
_Op = formatted_input_t; _Args = {std::vector<int, std::allocator<int> >}]’
/usr/include/c++/11/experimental/type_traits:245:9:   required by substitution
of ‘template<template<class ...> class _Op, class ... _Args> using is_detected
= typename std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
_Op, _Args ...>::value_t [with _Op = formatted_input_t; _Args =
{std::vector<int, std::allocator<int> >}]’
issue.cpp:15:4:   required from ‘constexpr const bool
is_ostreamable_v<std::vector<int> >’
issue.cpp:30:5:   required from here
/usr/include/c++/11/experimental/type_traits:245:9: error: invalid use of
incomplete type ‘struct
std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
formatted_input_t, std::vector<int, std::allocator<int> > >’
  245 |   using is_detected
      |         ^~~~~~~~~~~
In file included from /usr/include/c++/11/bits/move.h:57,
                 from /usr/include/c++/11/bits/nested_exception.h:40,
                 from /usr/include/c++/11/exception:148,
                 from /usr/include/c++/11/ios:39,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from issue.cpp:1:
/usr/include/c++/11/type_traits:2542:12: note: declaration of ‘struct
std::__detector<std::experimental::fundamentals_v2::nonesuch, void,
formatted_input_t, std::vector<int, std::allocator<int> > >’
 2542 |     struct __detector
      |            ^~~~~~~~~~

#2. CVISE reduced testcase
#include <experimental/type_traits>
#include <iostream>
#include <vector>
template <class T>
using formatted_input_t =
    decltype(std::declval<std::ostream>() << std::declval<T>());
template <class T>
bool is_ostreamable_v =
    std::experimental::is_detected<formatted_input_t, T>::value;
template <class T> constexpr bool is_ostreamable() {
  return std::experimental::is_detected<formatted_input_t, T>::value;
}
template <class T, std::enable_if_t<is_ostreamable<T>()> = true>
std::ostream operator<<(std::ostream, T);
int main() {
  using T = std::vector<int>;
  is_ostreamable_v<T>;
}

Reply via email to