Bug 174543 - Try to fix WTF::Function so we don't need explicit conversion on Windows
Summary: Try to fix WTF::Function so we don't need explicit conversion on Windows
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-15 09:29 PDT by Darin Adler
Modified: 2017-07-23 15:11 PDT (History)
1 user (show)

See Also:


Attachments
Patch (1.20 KB, patch)
2017-07-15 09:30 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2017-07-15 09:29:46 PDT
Try to fix WTF::Function so we don't need explicit conversion on Windows
Comment 1 Darin Adler 2017-07-15 09:30:01 PDT
Created attachment 315549 [details]
Patch
Comment 2 Darin Adler 2017-07-15 09:30:38 PDT
Trying out Yusuke’s suggestion:

"I'm not 100% confident, but can you try it `&testFunction` instead?"
Comment 3 Darin Adler 2017-07-15 10:16:32 PDT
Wow, seems like you were right Yusuke! Is that a bug in the Windows compiler, or what?
Comment 4 Yusuke Suzuki 2017-07-16 07:29:47 PDT
(In reply to Darin Adler from comment #3)
> Wow, seems like you were right Yusuke! Is that a bug in the Windows
> compiler, or what?

My guess is that Function's Callable/FunctionType becomes function instead of function pointer. And it seems that MSVC does not encourage implicit function to function pointer conversion in this case.
http://en.cppreference.com/w/cpp/language/implicit_conversion#Function_to_pointer

If the implicit conversion works, it becomes rvalue of the pointer to the function.

By using `&testFunction`, we explicitly convert a function to rvalue of a pointer to a function. Then, it works correctly.
Comment 5 Darin Adler 2017-07-17 18:44:44 PDT
I wonder if there’s a way to work around this in WTF::Function instead of my adding the & at each use.
Comment 6 Darin Adler 2017-07-23 15:11:35 PDT
I’m not going to bother with this for now.