Bug 169769

Summary: std::get for tuple should be declared before struct TupleHash is defined
Product: WebKit Reporter: Yoshiaki Jitsukawa <yoshiaki.jitsukawa>
Component: Web Template FrameworkAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: benjamin, cdumez, cmarcelo, commit-queue, dbates, don.olmstead, Hironori.Fujii, mjs
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
patch none

Description Yoshiaki Jitsukawa 2017-03-16 11:08:13 PDT
As TupleHash::hash() refers to std::get(std::tuple), it should be declared beforehand. Otherwise clang's two phase lookup cannot resolve the proper function.
Comment 1 Yoshiaki Jitsukawa 2017-03-16 11:55:17 PDT
Created attachment 304663 [details]
patch
Comment 2 Yoshiaki Jitsukawa 2017-03-16 11:58:31 PDT
Created attachment 304664 [details]
patch
Comment 3 Alex Christensen 2017-03-16 16:38:43 PDT
Comment on attachment 304664 [details]
patch

What file fails to compile without this?  We would ideally not add another #include to this widely-included file if we can get away with just including tuple before wtf/HashFunctions.h in the file that instantiates TupleHash
Comment 4 Yoshiaki Jitsukawa 2017-03-16 17:01:25 PDT
JSClassRef.cpp, for example. Adding #include <tuple> to it works fine.

The completeness of HashFunctions.h doesn't matter?
Comment 5 Yoshiaki Jitsukawa 2017-03-17 08:05:52 PDT
#include <utility>

template <typename T>
auto myget(const T& t)
{
	return std::get<0>(t);
}

#include <tuple>

int foo()
{
	return myget(std::tuple<int, int, int>(1, 2, 3));
}

---

Here's a simplified code which causes a compilation error with clang while MSVC is ok.
Comment 6 Yoshiaki Jitsukawa 2017-05-12 00:04:06 PDT
There seems to be two factors in this issue:
 - <tuple> is implicitly included or not
 - compiler does two phase lookup or not

On mac and ubuntu, <tuple> is implicitly included in HashFunctions.h.

On windows, <tuple> is not included there but cl compiler doesn't do two phase lookup so webkit can build. However if we use clang-cl with "-fno-delayed-template-parsing", which enables two phase lookup, the compiler reports compilation errors of std::get(std::tuple), so there's still a problem of header inclusion.

Anyways, if toolchain supports, passing "-fdelayed-template-parsing" (not "-fno-delayed-template-parsing") can be a workaround.
Comment 7 Don Olmstead 2017-11-21 16:16:16 PST

*** This bug has been marked as a duplicate of bug 179926 ***
Comment 8 Maciej Stachowiak 2020-06-01 14:53:30 PDT
Comment on attachment 304664 [details]
patch

Unflagging and obsoleting since this was resolved as a dupe.