https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124564
Bug ID: 124564
Summary: weird gcc warning with sub-coroutines and
std::ranges::elements_of
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nico at josuttis dot de
Target Milestone: ---
Not sure this is a compiler or library issue.
Consider https://www.godbolt.org/z/K6nYTvdce :
std::generator<int> subgen()
{
co_yield 1;
}
std::generator<int> gen()
{
co_yield std::ranges::elements_of(subgen());
}
With -Wall this yields a couple of warnings like this:
<source>: In function 'std::generator<int> subgen()':
<source>:4:21: warning: 'static void std::__gen::_Promise_alloc<void>::operator
delete(void*, std::size_t)' called on pointer returned from a mismatched
allocation function [-Wmismatched-new-delete]
4 | std::generator<int> subgen()
| ^~~~~~
In file included from <source>:2:
In static member function 'static void*
std::__gen::_Promise_alloc<void>::operator new(std::size_t)',
inlined from 'std::generator<int> subgen()' at <source>:4:21:
/cefs/22/22e6cdc013c8541ce3d1548e_consolidated/compilers_c++_x86_gcc_15.2.0/include/c++/15.2.0/generator:617:36:
note: returned from 'void* operator new(std::size_t)'
617 | auto __p = ::operator new(__nsz);
| ~~~~~~~~~~~~~~^~~~~~~
<source>: In function 'std::generator<int> gen()':