This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/63415] New: internal compiler error: unexpected expression âstatic_cast<int>(std::is_same<T, A1>{})â of kind static_cast_expr
- From: "tnozicka at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 30 Sep 2014 12:20:44 +0000
- Subject: [Bug c++/63415] New: internal compiler error: unexpected expression âstatic_cast<int>(std::is_same<T, A1>{})â of kind static_cast_expr
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63415
Bug ID: 63415
Summary: internal compiler error: unexpected expression
âstatic_cast<int>(std::is_same<T, A1>{})â of kind
static_cast_expr
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tnozicka at gmail dot com
Hi,
g++ asked me to submit a bug report, so here it is :)
=== ERROR ===
main.cpp:37:69: internal compiler error: unexpected expression
âstatic_cast<int>(std::is_same<T, A1>{})â of kind static_cast_expr
static constexpr int value = static_cast<int>(std::is_same<T, A1>{});
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
=== SOURCE ===
#include <type_traits>
template<typename T, typename A1, typename... Args>
struct CountType
{
static constexpr int value = CountType<T, A1>::value + CountType<T,
Args...>::value;
constexpr operator int() const
{
return value;
}
};
template<typename T, typename A1>
struct CountType<T, A1>
{
// static constexpr int value = static_cast<int>(std::is_same<T, A1>()); //
this works
static constexpr int value = static_cast<int>(std::is_same<T, A1>{});
constexpr operator int() const
{
return value;
}
};
template<typename T, typename... Args>
using CountDecayType = CountType<T, std::decay_t<Args>...>;
template<typename... Args>
void foo(Args&&... args)
{
int i = CountDecayType<int, Args...>{};
}
int main()
{
foo(5, 6L, 5, 5);
return 0;
}
=== g++ flags ===
-std=c++14 -pedantic-errors -Wall -Wextra -gdwarf-2
=== configure ===
Using built-in specs.
COLLECT_GCC=/opt/szn/bin/g++-4.9
COLLECT_LTO_WRAPPER=/opt/szn/lib/gcc/x86_64-linux-gnu/4.9.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: /home/tomas/packages/gcc/gcc-4.9.1/configure --prefix=/opt/szn
--program-suffix=-4.9 --enable-languages=c++ --disable-multilib --enable-shared
--enable-threads=posix --enable-checking=release --enable-__cxa_atexit
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --with-tune=generic
--enable-libstdcxx-time=yes --enable-libstdcxx-debug
--enable-version-specific-runtime-libs --enable-objc-gc --enable-clocale=gnu
--disable-install-libiberty --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --libdir=/opt/szn/lib --libexecdir=/opt/szn/lib
--infodir=/opt/szn/share/info-gcc-4.9 --localedir=/opt/szn/share/locale-gcc-4.9
--mandir=/opt/szn/share/man-gcc-4.9
--with-gxx-include-dir=/opt/szn/include/c++/4.9
Thread model: posix
gcc version 4.9.1 (GCC)