[llvm-bugs] [Bug 30576] New: [Modules] default ctor of member requires type to be visible when the containing class is instantiated

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 30 03:43:53 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30576

            Bug ID: 30576
           Summary: [Modules] default ctor of member requires type to be
                    visible when the containing class is instantiated
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: benny.kra at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk
    Classification: Unclassified

Created attachment 17385
  --> https://llvm.org/bugs/attachment.cgi?id=17385&action=edit
Packaged test case.

For this test case (also attached for convenience):

a.cc:
#include "a.h"
int main() {
  C c;
}

a.h:
#include "b.h"

struct C {
  Member m;
};

b.h:
struct Member {
  Member() {}
};

module map:
module a { header "a.h" }
module b { header "b.h" }

Clang emits:
$ clang -fmodules cxx-default-ctor.cpp
In module 'a' imported from cxx-default-ctor.cpp:5:
Inputs/cxx-default-ctor/a.h:3:8: error: missing '#include "b.h"'; definition of
      'Member' must be imported from module 'b' before it is required
struct C {
       ^
Inputs/cxx-default-ctor/b.h:1:8: note: previous definition is here
struct Member {
       ^
cxx-default-ctor.cpp:7:5: note: implicit default constructor for 'C' first
      required here
  C c;
    ^

It seems wrong to expose implementation details just because there's a default
ctor. Adding a user-defined ctor to 'Member' avoids the issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160930/95e987ef/attachment.html>


More information about the llvm-bugs mailing list