Recent failing tests in libc++

This past week, I checked in a bunch of code (and tests) having to do with the deduction guides features of C++17 - adding support for many of the standard library types. Some of the tests started failing - mostly (but not exclusively) on ARM. JF tried to fix some of the tests on Friday, but was not completely successful.

Today, I took a fresh look at the failures, and realized that all but one of them were on bots that were running clang-5. It appears that clang-5 has a bug where it mis-deduces the template arguments when it is handed something that looks like a copy constructor. (Alternately, it implicitly generates an incorrect template deduction guide and uses that.)

A simple example is:
std::optional o1(‘A’);
std::optional o2 = o1;

clang6, clang7 and gcc all agree that decltype(o2) is ‘std::optional’.
clang5 believes that the type is ‘std::optional<std::optional>’.

This was also causing failures in the deduction tests for the container adapters, and for std::array as well.

I have marked these tests as UNSUPPORTED in clang5.

Oh yes - and that “all but one” comment above? That was a *.fail test where clang5 and clang6 give one error message, and clang7 gives a different one. We check the error message to make sure we’re “failing for the right reason”.

std::optional opt;

clang5/clang6 gives a (IMHO) bogus error here:

declaration of variable ‘opt’ with deduced type ‘std::optional’ requires an initializer
clang7 (and later) give a better message:
no viable constructor or deduction guide for deduction of template arguments of ‘optional’

So now we look for either one.

I’m putting this out here so that if anyone else has trouble with implicit deduction guides in clang 5, hopefully they will find this.

– Marshall

Another possible diagnosis is that clang-5 generates no implicit deduction
guides - and only uses the explicitly provided ones.

-- Marshall

Clang 5 implemented the originally adopted proposal. The behaviour you’re referring to was introduced by P0620R0, which I think was not implemented until Clang 6. Perhaps we should bump the deduction guides feature test macro version for that paper?

Clang 5 implemented the originally adopted proposal. The behaviour you're
referring to was introduced by P0620R0, which I think was not implemented
until Clang 6.

That would explain what I'm seeing.

Perhaps we should bump the deduction guides feature test macro version for
that paper?

I don't see any mention of feature macros in P0620R0 :frowning:
Besides, I don't see how it will help now that clang 6 is out there.

-- Marshall

Thanks for tracking this Marshall!

Ouch yeah, fixing the deduction guides would have been nice.

Looks like latest changes for this came in late 2017 from:

https://reviews.llvm.org/rL320401

https://reviews.llvm.org/rL316292

Was the green dragon bot passing? It’s down now for maintenance, but I expect some of the tests should have been failing before your change.

Clang 5 implemented the originally adopted proposal. The behaviour you're
referring to was introduced by P0620R0, which I think was not implemented
until Clang 6.

That would explain what I'm seeing.

Perhaps we should bump the deduction guides feature test macro version
for that paper?

I don't see any mention of feature macros in P0620R0 :frowning:
Besides, I don't see how it will help now that clang 6 is out there.

We can bump the reported version for clang 6.0.1 and clang 7, at least.

Thanks for tracking this Marshall!

Ouch yeah, fixing the deduction guides would have been nice.

Looks like latest changes for this came in late 2017 from:

https://reviews.llvm.org/rL320401

https://reviews.llvm.org/rL316292

Was the green dragon bot passing? It’s down now for maintenance, but I expect some of the tests should have been failing before your change.

Answering my own question: the bot was disabled.

http://lab.llvm.org:8080/green/view/Libcxx/job/libcxx_abi/

I enable it. I’ll see if it has other failures.

I also committed a fix for the failing tests on apple-clang-9: r333479.