Bug 111579

Summary: Fix GCC with C++11 build
Product: WebKit Reporter: Allan Sandfeld Jensen <allan.jensen>
Component: Tools / TestsAssignee: Allan Sandfeld Jensen <allan.jensen>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, ap, esprehn+autocc, japhet, macpherson, menard, ojan.autocc, rakuco, webkit.review.bot, zan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Allan Sandfeld Jensen 2013-03-06 07:36:17 PST
WebCore does not currently build with GCC if C++11 is enabled. The issue is caused by private virtual destructors which are meaningless since  private destructors are considered deleted and can not be virtual.
Comment 1 Allan Sandfeld Jensen 2013-03-06 07:38:05 PST
Created attachment 191747 [details]
Patch
Comment 2 Allan Sandfeld Jensen 2013-03-06 07:43:47 PST
Well, more specifically while virtual destructors can be private, you can not inherit from the class if they are, which causes compile errors in MemoryInstrumentation.
Comment 3 Alexey Proskuryakov 2013-03-06 17:01:33 PST
Comment on attachment 191747 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=191747&action=review

> Source/WebCore/ChangeLog:8
> +        Private destructors are considered deleted and can not be virtual.

This is surprising. Is that a gcc bug?
Comment 4 Anders Carlsson 2013-03-06 19:33:45 PST
What version of GCC is this?
Comment 5 Allan Sandfeld Jensen 2013-03-07 02:36:12 PST
(In reply to comment #3)
> (From update of attachment 191747 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=191747&action=review
> 
> > Source/WebCore/ChangeLog:8
> > +        Private destructors are considered deleted and can not be virtual.
> 
> This is surprising. Is that a gcc bug?

That statement wasn't precise, see comment #2.

I think MSVC has the same issue, but can be disabled as a warning. The following hack in MemoryInstrumentation.h, will probably also be fixed by this patch:
#pragma warning(disable: 4624) // Disable warning: destructor could not be generated because a base class destructor is inaccessible.
Comment 6 Allan Sandfeld Jensen 2013-03-07 02:45:48 PST
Created attachment 191960 [details]
Patch

Corrected changelog
Comment 7 Allan Sandfeld Jensen 2013-03-07 02:48:45 PST
(In reply to comment #4)
> What version of GCC is this?

4.7
Comment 8 Alexey Proskuryakov 2013-03-07 09:53:18 PST
Sorry for not noticing the comment at first. Anyway, deferring to Anders for review.
Comment 9 Allan Sandfeld Jensen 2013-03-13 04:11:17 PDT
Anders, does this look okay to you?
Comment 10 Anders Carlsson 2013-03-13 13:53:16 PDT
What's the error message again?
Comment 11 Allan Sandfeld Jensen 2013-03-15 06:17:58 PDT
(In reply to comment #10)
> What's the error message again?

Here is one example:

/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h: In instantiation of 'struct WTF::MemoryInstrumentation::IsInstrumented<WebCore::StyleRuleCSSStyleDeclaration>::Base':
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:148:41:   required by substitution of 'template<class U> static WTF::MemoryInstrumentation::IsInstrumented<Type>::no WTF::MemoryInstrumentation::IsInstrumented::deduce(U*, WTF::MemoryInstrumentation::IsInstrumented<Type>::Helper<void (WTF::MemoryInstrumentation::IsInstrumented<Type>::BaseMixin::*)(WTF::MemoryObjectInfo*)const, (& U:: reportMemoryUsage)>*) [with U = U; Type = WebCore::StyleRuleCSSStyleDeclaration] [with U = WTF::MemoryInstrumentation::IsInstrumented<WebCore::StyleRuleCSSStyleDeclaration>::Base]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:152:76:   required from 'const bool WTF::MemoryInstrumentation::IsInstrumented<WebCore::StyleRuleCSSStyleDeclaration>::result'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:283:5:   required from 'void WTF::reportMemoryUsage(const T*, WTF::MemoryObjectInfo*) [with T = WebCore::StyleRuleCSSStyleDeclaration]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:292:9:   required from 'void WTF::MemoryInstrumentation::addObjectImpl(const T*, WTF::MemoryObjectInfo*, WTF::MemberType, const char*) [with T = WebCore::StyleRuleCSSStyleDeclaration]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:316:5:   required from 'void WTF::MemoryInstrumentation::addObjectImpl(const WTF::RefPtr<T>*, WTF::MemoryObjectInfo*, WTF::MemberType, const char*) [with T = WebCore::StyleRuleCSSStyleDeclaration]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:186:13:   required from 'static void WTF::MemoryInstrumentation::MemberTypeTraits<T>::addObject(WTF::MemoryInstrumentation*, const T&, WTF::MemoryObjectInfo*, const char*, WTF::MemberType) [with T = WTF::RefPtr<WebCore::StyleRuleCSSStyleDeclaration>; WTF::MemoryInstrumentation = WTF::MemoryInstrumentation]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:171:9:   required from 'void WTF::MemoryInstrumentation::addObject(const T&, WTF::MemoryObjectInfo*, const char*, WTF::MemberType) [with T = WTF::RefPtr<WebCore::StyleRuleCSSStyleDeclaration>]'
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:245:13:   required from 'void WTF::MemoryClassInfo::addMember(const M&, const char*, WTF::MemberType) [with M = WTF::RefPtr<WebCore::StyleRuleCSSStyleDeclaration>]'
/src/webkit/Source/WebCore/css/CSSFontFaceRule.cpp:78:70:   required from here
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:141:16: error: deleted function 'virtual WTF::MemoryInstrumentation::IsInstrumented<WebCore::StyleRuleCSSStyleDeclaration>::Base::~Base()'
In file included from /src/webkit/Source/WebCore/css/CSSFontFaceRule.cpp:25:0:
/src/webkit/Source/WebCore/css/PropertySetCSSStyleDeclaration.h:105:13: error: overriding non-deleted function 'virtual WebCore::StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration()'
In file included from /src/webkit/Source/WebCore/platform/PlatformMemoryInstrumentation.h:34:0,
                 from /src/webkit/Source/WebCore/dom/WebCoreMemoryInstrumentation.h:34,
                 from /src/webkit/Source/WebCore/css/CSSRule.h:26,
                 from /src/webkit/Source/WebCore/css/CSSFontFaceRule.h:25,
                 from /src/webkit/Source/WebCore/css/CSSFontFaceRule.cpp:23:
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:141:16: note: 'virtual WTF::MemoryInstrumentation::IsInstrumented<WebCore::StyleRuleCSSStyleDeclaration>::Base::~Base()' is implicitly deleted because the default definition would be ill-formed:
In file included from /src/webkit/Source/WebCore/css/CSSFontFaceRule.cpp:25:0:
/src/webkit/Source/WebCore/css/PropertySetCSSStyleDeclaration.h:105:13: error: 'virtual WebCore::StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration()' is private
In file included from /src/webkit/Source/WebCore/platform/PlatformMemoryInstrumentation.h:34:0,
                 from /src/webkit/Source/WebCore/dom/WebCoreMemoryInstrumentation.h:34,
                 from /src/webkit/Source/WebCore/css/CSSRule.h:26,
                 from /src/webkit/Source/WebCore/css/CSSFontFaceRule.h:25,
                 from /src/webkit/Source/WebCore/css/CSSFontFaceRule.cpp:23:
/src/webkit/Source/WTF/wtf/MemoryInstrumentation.h:141:16: error: within this context
Comment 12 Allan Sandfeld Jensen 2013-03-26 07:01:29 PDT
Anders: Any input on the build error?
Comment 13 Allan Sandfeld Jensen 2013-04-05 09:11:33 PDT
Comment on attachment 191960 [details]
Patch

Clearing flags on attachment: 191960

Committed r147751: <http://trac.webkit.org/changeset/147751>
Comment 14 Allan Sandfeld Jensen 2013-04-05 09:11:38 PDT
All reviewed patches have been landed.  Closing bug.