[RFC] libstdc++: fix declaration and definition mismatch for _GLIBCXX20_CONSTEXPR

Jonathan Wakely jwakely.gcc@gmail.com
Mon May 19 11:17:52 GMT 2025


On Mon, 19 May 2025 at 12:16, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Mon, 19 May 2025 at 12:09, Alexey Lapshin
> <alexey.lapshin@espressif.com> wrote:
> >
> > Thanks for the quick response,
> >
> > I just want to save some space for embedded apps that are using c++
> > Related issue is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93008
> > So, I want to drop "constexpr" for templates.
>
> That would be non-conforming though, so we absolutely can't do that.

If you want to prevent inlining of constexpr functions that aren't
good candidates for inlining, then you should add the cold attribute
to specific functions in carefully chosen places, not just redefine
_GLIBCXX20_CONSTEXPR, because that will break *everything*.


>
> > I'm not familiar with the libstdc++ source code and coding style.
> > Is having mixed declarations and definitions intentional in libstdc++?
>
> Do you mean defining some functions inline in the class body, instead
> of only declaring them there and defining them all outside the class
> body?
> Yes, that's intentional, and IMHO a fairly conventional style for C++ classes.


More information about the Libstdc++ mailing list