<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - -fmodule triggers error: reference to 'd' is ambiguous"
   href="https://bugs.llvm.org/show_bug.cgi?id=32943">32943</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-fmodule triggers error: reference to 'd' is ambiguous
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Modules
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mail@milianw.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18412" name="attach_18412" title="MWE to reproduce the issue">attachment 18412</a> <a href="attachment.cgi?id=18412&action=edit" title="MWE to reproduce the issue">[details]</a></span>
MWE to reproduce the issue

I wanted to test the state of module support in clang 4 and how it impacts the
compile speed of KDE applications. While doing so, I found a nasty issue which
I tried to minimize as good as possible. Sadly, the test case is still pretty
large as it still depends on Qt. I do hope that someone can look into it
nevertheless. If it's too large, I will try to reduce the complexity of my
current MWE and get rid of the Qt dependency there, by somehow copying whatever
QList does to trigger this issue.

Anyhow, for now here's the clang command that triggers the issue:

~~~~~~~~~~~~~~~~~~
$ rm -Rf /tmp/org.llvm.clang.milian/; clang++ -isystem /usr/include/qt -isystem
/usr/include/qt/QtCore -I../A/  -fmodules -fPIC  -std=c++11 -o b.cpp.o -c
b.cppIn module 'QtCore' imported from ./b.h:3:
/usr/include/qt/QtCore/qlist.h:806:38: error: reference to 'd' is ambiguous
    : QListSpecialMethods<T>(l), d(l.d)
                                     ^
b.cpp:8:17: note: in instantiation of member function 'QList<int>::QList'
requested here
    auto copy = b.list;
                ^
/usr/include/qt/QtCore/qlist.h:147:43: note: candidate found by name lookup is
'QList<int>::d'
    union { QListData p; QListData::Data *d; };
                                          ^
/usr/include/qt/QtCore/qlist.h:147:43: note: candidate found by name lookup is
'QList<int>::d'
/usr/include/qt/QtCore/qlist.h:814:48: error: reference to 'p' is ambiguous
                    reinterpret_cast<Node *>(l.p.begin()));
                                               ^
/usr/include/qt/QtCore/qlist.h:147:23: note: candidate found by name lookup is
'QList<int>::p'
    union { QListData p; QListData::Data *d; };
                      ^
/usr/include/qt/QtCore/qlist.h:147:23: note: candidate found by name lookup is
'QList<int>::p'
2 errors generated.
~~~~~~~~~~~~~~~~~~

Removing `-fmodules` fixes this issue. In the attached tarball you find the two
folders that trigger this issue. Go the B/ then invoke the above command to
trigger the bug. But first, add this modulemap for QtCore:

~~~~~~~~~~~~~~~~~~
$ cat /usr/include/qt/QtCore/module.modulemap
module QtCore {
    umbrella header "QtCore"
    export *
}
~~~~~~~~~~~~~~~~~~

Note that `b.h` only includes the (empty) `a.h`, but the module of `a.h`
includes the `other.h` header which uses a `QList<int>`, just like `b.h`.

Can someone explain what's happening here? Can it be work-arounded by modifying
the module maps? I'd love to resolve this issue, as the other

Thanks</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>