New issue
Advanced search Search tips

Issue 746343 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

WTF::Function gets shadowed by other objects named Function

Project Member Reported by brat...@opera.com, Jul 19 2017

Issue description

Classes named Function will shadow the template Function in WTF/Functional.h. The result can be spectacular template instantiation errors.

For instance
ninja -t msvc -e environment.x86 -- "c:\program files (x86)\microsoft visual studio 14.0\vc\bin\amd64_x86/cl.exe" /nologo /showIncludes  @obj/third_party/WebKit/Source/core/unit_tests/testfile.obj.rsp /c ../../third_party/WebKit/Source/core/workers/testfile.cpp /Foobj/third_party
/WebKit/Source/core/unit_tests/testfile.obj /Fd"obj/third_party/WebKit/Source/core/unit_tests_cc.pdb"
../../third_party/WebKit/Source\core/workers/WorkerThread.h(247): error C2947: expecting '>' to terminate template-argument-list, found '<'
../../third_party/WebKit/Source\core/workers/WorkerThread.h(247): error C2628: 'std::unique_ptr<blink::`anonymous-namespace'::Function,std::default_delete<_Ty>>' followed by 'void' is illegal (did you forget a ';'?)
        with
        [
            _Ty=blink::`anonymous-namespace'::Function
        ]
../../third_party/WebKit/Source\core/workers/WorkerThread.h(247): error C2061: syntax error: identifier 'threadAffinity'
../../third_party/WebKit/Source\platform/CrossThreadFunctional.h(32): error C2947: expecting '>' to terminate template-argument-list, found '<'
../../third_party/WebKit/Source\platform/CrossThreadFunctional.h(32): error C2936: 'base::MakeUnboundRunType<Functor,Args...>': template-id redefined as a global data variable
../..\base/bind.h(29): note: see declaration of 'base::MakeUnboundRunType<Functor,Args...>'

or 

e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): error C2672: 'blink::CrossThreadBind': no matching overloaded function found
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): error C2893: Failed to specialize function template 'std::unique_ptr<WTF::Function<internal::MakeUnboundRunTypeImpl<Functor,BoundArgs...>::Type,WTF::kCrossThreadAffinity>,std::default_delete<_Ty>> blink::CrossThreadBind(FunctionType,Ps &&...)'
        with
        [
            _Ty=WTF::Function<internal::MakeUnboundRunTypeImpl<Functor,BoundArgs...>::Type,WTF::kCrossThreadAffinity>
        ]
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): note: With the following template arguments:
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): note: 'FunctionType=void (__cdecl *)(void)'
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): note: 'Ps={}'
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp(63): error C2661: 'blink::WebTaskRunner::PostTask': no overloaded function takes 1 arguments
e:\b\c\b\win\src\out\release\gen\third_party\webkit\source\core\animation\../../../../../../../../third_party/WebKit/Source/core/workers/DedicatedWorkerTest.c
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jul 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/352ac7aa0c0eebcce1ec493a6716f210a4f7d27b

commit 352ac7aa0c0eebcce1ec493a6716f210a4f7d27b
Author: Daniel Bratell <bratell@opera.com>
Date: Wed Jul 19 15:15:28 2017

Avoid using the name Function since it collides with WTF::Function

If a class named Function is created and the header
platform/wtf/Functional.h included, any attempt at using WTF::Function
will fail with a lot of strange template instantiation errors.

This can happen unexpectedly in jumbo builds so to avoid that error
this patch renames a testing class that used to be 
named Function, ReaderFunction.

R=fs@opera.com

Bug:  746343 
Change-Id: I498ecf4f8cb293de634c40060a2df34c78a23e09
Reviewed-on: https://chromium-review.googlesource.com/574864
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#487870}
[modify] https://crrev.com/352ac7aa0c0eebcce1ec493a6716f210a4f7d27b/third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp

Comment 2 by brat...@opera.com, Nov 20 2017

Cc: yutak@chromium.org
Status: Fixed (was: Assigned)
All known cases fixed, and WTF::Function is being removed (thanks yutak!) so no need to keep this bug around.

Sign in to add a comment