Repository navigation
Including <functional> and enabling CppUTest breaks compile on GCC 15.2 #1898
Copy link
Copy link
Open
Description
Using GCC 15.2 and using the header causes a slew of compiler errors when CppUTest is enabled as a library.
Minimal reproduction
cmake_minimum_required (VERSION 3.14)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_C_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BUILD_TYPE Debug)
include(FetchContent)
FetchContent_Declare(cpputest
GIT_REPOSITORY https://github.com/cpputest/cpputest.git
GIT_TAG master
)
FetchContent_MakeAvailable(CppUTest)
project(cpputest_functional_bug LANGUAGES C CXX)
enable_testing()
add_executable(test_functional test_functional.cpp)
target_link_libraries(test_functional PRIVATE CppUTest::CppUTest)
add_test(test_functional test_functional)
#include <functional>
int main()
{
return 0;
}
Compiler error
[1/2] Building CXX object CMakeFiles/test_functional.dir/test_functional.cpp.o
FAILED: [code=1] CMakeFiles/test_functional.dir/test_functional.cpp.o
/usr/bin/c++ -DCPPUTEST_HAVE_FORK -DCPPUTEST_HAVE_KILL -DCPPUTEST_HAVE_PTHREAD_MUTEX_LOCK -DCPPUTEST_HAVE_STRDUP -DCPPUTEST_HAVE_WAITPID -DCPPUTEST_USE_LONG_LONG=1 -DCPPUTEST_USE_MEM_LEAK_DETECTION=1 -DCPPUTEST_USE_STD_CPP_LIB=1 -DCPPUTEST_USE_STD_C_LIB=1 -I/home/tims/Projects/cpputest_functional_bug/build/_deps/cpputest-src/include -I/home/tims/Projects/cpputest_functional_bug/build/_deps/cpputest-build -g -std=gnu++23 -includeCppUTest/MemoryLeakDetectorForceInclude.h -MD -MT CMakeFiles/test_functional.dir/test_functional.cpp.o -MF CMakeFiles/test_functional.dir/test_functional.cpp.o.d -o CMakeFiles/test_functional.dir/test_functional.cpp.o -c /home/tims/Projects/cpputest_functional_bug/test_functional.cpp
In file included from /usr/include/c++/15/functional:61,
from /home/tims/Projects/cpputest_functional_bug/test_functional.cpp:1:
/usr/include/c++/15/bits/std_function.h: In static member function ‘static void std::_Function_base::_Base_manager<_Functor>::_M_create(std::_Any_data&, _Fn&&, std::true_type)’:
/usr/include/c++/15/bits/std_function.h:154:20: error: ‘__dest’ does not name a type; did you mean ‘__dev_t’? [-Wtemplate-body]
154 | ::new (__dest._M_access()) _Functor(std::forward<_Fn>(__f));
| ^~~~~~
| __dev_t
/usr/include/c++/15/bits/std_function.h:154:26: error: expected ‘)’ before ‘.’ token [-Wtemplate-body]
154 | ::new (__dest._M_access()) _Functor(std::forward<_Fn>(__f));
| ^
/usr/include/c++/15/bits/std_function.h:154:19: note: to match this ‘(’
154 | ::new (__dest._M_access()) _Functor(std::forward<_Fn>(__f));
| ^
In file included from /usr/include/c++/15/bits/hashtable.h:37,
from /usr/include/c++/15/bits/unordered_map.h:33,
from /usr/include/c++/15/unordered_map:43,
from /usr/include/c++/15/functional:65:
/usr/include/c++/15/bits/hashtable_policy.h: In member function ‘std::__detail::_Hashtable_alloc<_NodeAlloc>::__node_type* std::__detail::_Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&& ...)’:
/usr/include/c++/15/bits/hashtable_policy.h:1555:20: error: expected type-specifier before ‘(’ token [-Wtemplate-body]
1555 | ::new ((void*)__n) __node_type;
| ^
/usr/include/c++/15/bits/hashtable_policy.h:1555:20: error: expected ‘)’ before ‘(’ token [-Wtemplate-body]
1555 | ::new ((void*)__n) __node_type;
| ~^
| )
/usr/include/c++/15/bits/hashtable_policy.h:1555:21: error: expected primary-expression before ‘void’ [-Wtemplate-body]
1555 | ::new ((void*)__n) __node_type;
| ^~~~
In file included from /usr/include/c++/15/bits/hashtable.h:42:
/usr/include/c++/15/bits/node_handle.h: In member function ‘void std::_Node_handle_common<_Val, _NodeAlloc>::_M_move(std::_Node_handle_common<_Val, _NodeAlloc>&&)’:
/usr/include/c++/15/bits/node_handle.h:157:16: error: expected type-specifier [-Wtemplate-body]
157 | ::new (std::__addressof(_M_alloc)) _NodeAlloc(__nh._M_alloc.release());
| ^~~
/usr/include/c++/15/bits/node_handle.h:157:16: error: expected ‘)’ [-Wtemplate-body]
/usr/include/c++/15/bits/node_handle.h:157:15: note: to match this ‘(’
157 | ::new (std::__addressof(_M_alloc)) _NodeAlloc(__nh._M_alloc.release());
| ^
In file included from /usr/include/c++/15/functional:76:
/usr/include/c++/15/bits/move_only_function.h: In member function ‘void std::_Mofunc_base::_M_init(_Args&& ...)’:
/usr/include/c++/15/bits/move_only_function.h:79:18: error: ‘_M_storage’ does not name a type; did you mean ‘_Storage’? [-Wtemplate-body]
79 | ::new (_M_storage._M_addr()) _Tp(std::forward<_Args>(__args)...);
| ^~~~~~~~~~
| _Storage
/usr/include/c++/15/bits/move_only_function.h:79:28: error: expected ‘)’ before ‘.’ token [-Wtemplate-body]
79 | ::new (_M_storage._M_addr()) _Tp(std::forward<_Args>(__args)...);
| ^
/usr/include/c++/15/bits/move_only_function.h:79:17: note: to match this ‘(’
79 | ::new (_M_storage._M_addr()) _Tp(std::forward<_Args>(__args)...);
| ^
/usr/include/c++/15/bits/move_only_function.h: In static member function ‘static void std::_Mofunc_base::_S_manage(_Storage&, _Storage*)’:
/usr/include/c++/15/bits/move_only_function.h:163:24: error: ‘__target’ does not name a type; did you mean ‘__pair_get’? [-Wtemplate-body]
163 | ::new (__target._M_addr()) _Tp(std::move(*__rval));
| ^~~~~~~~
| __pair_get
/usr/include/c++/15/bits/move_only_function.h:163:32: error: expected ‘)’ before ‘.’ token [-Wtemplate-body]
163 | ::new (__target._M_addr()) _Tp(std::move(*__rval));
| ^
/usr/include/c++/15/bits/move_only_function.h:163:23: note: to match this ‘(’
163 | ::new (__target._M_addr()) _Tp(std::move(*__rval));
| ^
ninja: build stopped: subcommand failed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
thetic commentedon Oct 12, 2026
https://cpputest.github.io/manual.html#conflicts-with-operator-new-macros-stl