Thanks to visit codestin.com
Credit goes to github.com

Skip to content

"invalid application of 'sizeof' to an incomplete type" in msvc mode #20711

@nico

Description

@nico
Bugzilla Link 20337
Resolution FIXED
Resolved on Sep 07, 2015 01:04
Version unspecified
OS All
Blocks #12849
CC @majnemer,@zygoloid,@rnk

Extended Description

(similar to issue 20221, but this is with clang r213197, so it does have the fix for that)

Consider:

$ cat test.cc
template class OwnPtr {
public:
~OwnPtr()
{
_Static_assert((sizeof(T) > 0), "TypeMustBeComplete");
}
};

class SVGElement {
public:
virtual ~SVGElement();
};

class ScriptLoader;

class SVGScriptElement final : public SVGElement {
virtual bool isStructurallyExternal() const { return hasSourceAttribute(); }
virtual bool hasSourceAttribute() const ;

OwnPtr<ScriptLoader> m_loader;

};

$ ../../llvm-build/bin/clang -c test.cc -std=c++11 # Works.
$ ../../llvm-build/bin/clang -c test.cc -target i386-pc-windows-msvc
test.cc:5:25: error: invalid application of 'sizeof' to an incomplete type 'ScriptLoader'
_Static_assert((sizeof(T) > 0), "TypeMustBeComplete");
^~~~~~~~~
test.cc:16:7: note: in instantiation of member function 'OwnPtr::~OwnPtr' requested here
class SVGScriptElement final : public SVGElement {
^
test.cc:14:7: note: forward declaration of 'ScriptLoader'
class ScriptLoader;
^
1 error generated.

This builds fine with cl.exe too.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions