[PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed May 24 17:54:53 PDT 2017

On 24 May 2017 3:19 pm, "Tim Northover" <t.p.northover at gmail.com> wrote:

On 24 May 2017 at 15:06, Richard Smith <richard at metafoo.co.uk> wrote:
> I think this is expected. Clang has an extension where it treats 1.0if as
> _Complex float if no operator""if is available;

Since it's breaking some bots, I've reverted my commit while we hash
this out. r303813.

Sounds good.

> libc++ has an extension
> where std::complex<float> can be initialized from _Complex float. For the
> same reason, that code has historically worked in C++11 and C++98 modes.

Are you sure? It looks like it does an implicit cast to float
(discarding the imaginary part) and then calls the "complex(float,
float = 0.0)" constructor to me.

Yikes :-( Maybe libc++ *should* have that extension then. It sounds like
we'll silently get the wrong value for any attempt at std::complex /
_Complex interop right now:

_Complex float a;
std::complex<float> b = a; // discards imaginary component

That seems pretty scary.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170524/55f6b817/attachment.html>

More information about the cfe-commits mailing list