[cfe-dev] More windows breakage

AlisdairM(public) public at alisdairm.net
Wed Jul 1 07:55:30 PDT 2009

Sorry - I'm in the middle of subscribing to the cfe-commits list so can't reply directly to the actual commit:

Commit r74539 by Edwin Torok breaks at link time with MSVC.

The cause is the following:

+template<typename TargetInfo>
+class OSTargetInfo : public TargetInfo {
+  virtual void getOSDefines(const LangOptions &Opts, const char *Triple,
+                            std::vector<char> &Defines) const=0;
+  OSTargetInfo(const std::string& triple) : TargetInfo(triple) {}
+  virtual void getTargetDefines(const LangOptions &Opts,
+                                std::vector<char> &Defines) const {
+    TargetInfo::getTargetDefines(Opts, Defines);
+    getOSDefines(Opts, TargetInfo::getTargetTriple(), Defines);

Here, TargetInfo is used as a template parameter name, but it is also the name of the fundamental base class of types that will be used to instantiate the template.  Therefore, the line 

    TargetInfo::getTargetDefines(Opts, Defines);

is being dispatched to the base class called TargetInfo, rather than the type referred to by the template parameter name TargetInfo.  As this is a pure abstract method, I presumed static dispatch should have been a compile-time rather than link-time error, but apparently not with MSVC.

Patch attached.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetInfo.patch
Type: application/octet-stream
Size: 1141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090701/55688be2/attachment.obj>

More information about the cfe-dev mailing list