https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65919
Bug ID: 65919
Summary: Regression - GCC 5.1 with options "-g -std=c++14"
fails to compile multiple lambdas used as default
function parameters
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drew.dormann at gmail dot com
Target Milestone: ---
The following program compiles with GCC 4.9, but will not compile using GCC 5.1
Command:
g++ -std=c++14 -g TEST.cpp
Source:
#include
struct TestClass
{
static void do_things( std::function first = []{},
std::function second = []{} );
};
int main()
{
TestClass::do_things();
}
Output:
TEST.cpp:12:1: error: ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_init_functor(std::_Any_data&,
_Functor&&, std::false_type) [with _Functor = TestClass::;
std::false_type = std::integral_constant]’ conflicts with a
previous declaration
}
^
In file included from TEST.cpp:1:0:
/usr/include/c++/5/functional:1786:2: note: previous declaration ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_init_functor(std::_Any_data&,
_Functor&&, std::false_type) [with _Functor = TestClass::;
std::false_type = std::integral_constant]’
_M_init_functor(_Any_data& __functor, _Functor&& __f, false_type)
^
/usr/include/c++/5/functional:1786:2: note: a later -fabi-version= (or =0)
avoids this error with a change in mangling
TEST.cpp:12:1: error: ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_destroy(std::_Any_data&,
std::false_type) [with _Functor = TestClass::; std::false_type =
std::integral_constant]’ conflicts with a previous declaration
}
^
In file included from TEST.cpp:1:0:
/usr/include/c++/5/functional:1724:2: note: previous declaration ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_destroy(std::_Any_data&,
std::false_type) [with _Functor = TestClass::; std::false_type =
std::integral_constant]’
_M_destroy(_Any_data& __victim, false_type)
^
/usr/include/c++/5/functional:1724:2: note: a later -fabi-version= (or =0)
avoids this error with a change in mangling
TEST.cpp:12:1: error: ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_clone(std::_Any_data&, const
std::_Any_data&, std::false_type) [with _Functor = TestClass::;
std::false_type = std::integral_constant]’ conflicts with a
previous declaration
}
^
In file included from TEST.cpp:1:0:
/usr/include/c++/5/functional:1708:2: note: previous declaration ‘static void
std::_Function_base::_Base_manager<_Functor>::_M_clone(std::_Any_data&, const
std::_Any_data&, std::false_type) [with _Functor = TestClass::;
std::false_type = std::integral_constant]’
_M_clone(_Any_data& __dest, const _Any_data& __source, false_type)
^
/usr/include/c++/5/functional:1708:2: note: a later -fabi-version= (or =0)
avoids this error with a change in mangling
Version:
g++ -v
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.1.0 (Ubuntu 5.1.0-0ubuntu11~14.04.1)
Observations:
The code will compile if any one of the following changes are made.
- Use g++-4.9
- Compile without the "-g" option
- Remove either parameter from "do_things" prototype
- Make "do_things" prototype a global function instead of a static member
funtion.
- Change the default parameters from a "do nothing" lambda to a "do nothing"
function name.