Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Lambda incorrectly passes SFINAE check for bool conversion in Objective-C++ #43537

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR44567
Status NEW
Importance P normal
Reported by Rajveer Aujla (rajveer_aujla@hotmail.com)
Reported on 2020-01-16 05:46:38 -0800
Last modified on 2020-01-16 06:56:39 -0800
Version unspecified
Hardware Macintosh MacOS X
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments main.mm (829 bytes, text/x-csrc)
Blocks
Blocked by
See also

Created attachment 23020 Code sample

The attached file has a SNIFAE check to see if a type T can be converted to a bool (bool(T)), and a set of execute functions where the correct one is picked based on this check. When compiled as C++17, this check correctly fails when the type T is a lambda and the file type is .cpp.

If the file is renamed to .mm however (to make the file be compiled as Objective-C++), the SNIFAE check incorrectly passes, which leads to the incorrect execute function being invoked. This then fails as the lambda is attempted to be converted to an Objective-C block, with the following error:

Call to implicitly-deleted copy constructor of 'const (lambda at .../main.mm:68:25)'

This error message is correct, however the compiler shouldn't get to this stage since the template check should fail for Objective-C++ too.

Quuxplusone commented 4 years ago

Attached main.mm (829 bytes, text/x-csrc): Code sample

Quuxplusone commented 4 years ago
Build environment:

OS: Mac OS 10.15.2
IDE: Xcode 11.3
Compiler: Apple Clang 11
Quuxplusone commented 4 years ago

Ugh, SFINAE and SNIFAE.