Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang-cl confuses variable method with class constructor when named the same, within noexcept(...) #36003

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37030
Status NEW
Importance P normal
Reported by Joel Frederico (jtfrederico@hrl.com)
Reported on 2018-04-06 00:18:00 -0700
Last modified on 2018-04-06 17:18:20 -0700
Version 6.0
Hardware PC other
CC heavenandhell171@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments main.cpp (294 bytes, text/x-modelica)
Blocks
Blocked by
See also
Created attachment 20168
Example of bug

Overview
========

When trying to automatically determine if a templated method is noexcept, clang-
cl confuses an argument's method for the class's constructor when named the
same. It also seems to be unable to find the variable's method. It's easiest to
refer to the simple example I've created, see attached.

Steps to Reproduce
==================

Compile the example main.cpp file with clang-cl, no extra switches required.

Actual Results
==============

When compiling main.cpp with clang-cl, a warning and two errors are produced.

Line 17 warning: explicit constructor calls are a Microsoft extension. It
appears that the compiler is mistaking `bar()' part of `t.bar()' for the
constructor for the class `bar'.

Line 17 error: no member named 'bar' in 'A': This isn't true, there is a member
`bar' in `A'.

Line 17 error: no member named 'bar' in 'B': This isn't true, there is a member
`bar' in `B'.

Expected Results
================

A working binary.

Build Date & Hardware
=====================

Windows 7 Clang-cl 5.0.1 64-bit from http://releases.llvm.org/download.html.

Additional Builds and Platforms
===============================

MacOS 10.12.6, Clang-cl 5.0.1 and 6.0.0 from macports has this bug as well. I
don't quite know how clang-cl exists on MacOS, but it does.

Additional Information
======================

Clang (on MacOS) and clang++ do not have this issue and produce working
binaries when using the flag -std=c++11.
Quuxplusone commented 6 years ago

Attached main.cpp (294 bytes, text/x-modelica): Example of bug

Quuxplusone commented 6 years ago
It doesn't look like this is specific to noexcept, for example, replace:

  noexcept(noexcept(t.bar()))

by

  decltype(t.bar())

and clang-cl gives the same error.

The flag -fno-ms-extensions suppresses the error, but then we can't use
Microsoft headers (like Windows SDK).