[PATCH] [libc++] In C++11 GNU extension mode, start emulating libstdc++'s use of constexpr.

Marshall Clow mclow.lists at gmail.com
Wed Nov 27 16:16:44 PST 2013


On Nov 26, 2013, at 2:04 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:

> Hi rsmith, howard.hinnant,
> 
> libstdc++ always declares various entities as constexpr if C++14 makes
> them constexpr, even in C++11 mode.

Well, that’s just wrong. ;-)

> To support programs which rely on this
> behavior, start applying constexpr to those entities in C++11 mode only if
> GNU extensions are enabled (i.e. -std=gnu++11).

How many programs are there that rely on this behavior? [ Clearly, none of them are ‘old’ ]

Why don’t we just tell them: “You’re relying on a bug in libstdc++" - and suggest that they take it up with Jonathan Wakely? ;-)

(see LWG issue #2013 for a definitive response)

In 17.6.5.6 [constexpr.functions], change paragraph 1 to:

	This standard explicitly requires that certain standard library functions are constexpr [dcl.constexpr]. An implementation shall not declare any standard library function signature asconstexpr except for those where it is explicitly required. Within any header that provides any non-defining declarations of constexpr functions or constructors an implementation shall provide corresponding definitions.

— Marshall





More information about the cfe-commits mailing list