compilation failure using gcc 4.7.2
Mikael Gerdin
mikael.gerdin at oracle.com
Thu Nov 15 00:49:19 PST 2012
David,
On 2012-11-15 05:39, David Holmes wrote:
> On 15/11/2012 2:13 PM, Coleen Phillimore wrote:
>>
>> David,
>>
>> I think adding this-> to these is the best way to fix these, and we've
>> been fixing similar bugs the same way. I don't think anyone preferred
>> adding "using" directives, at least for this sort of compilation error.
>
> That should have been debated when 7172226 was fixed. Personally I think
> adding this-> all over the place is a PITA, particularly as each tweak
> of gcc seems to add a need for more of them in more places.
>
>> I'm not sure why the compilation error exists. It seems that the
>> compiler should be able to resolve these calls with the same template
>> instantiation as the function, but I guess not.
>
> I'm not going to even try and guess what a C++ compiler might or might
> not be able to do :) But yes it seems natural to me that given foo() the
> first place you look for foo() is in "this" :( But I'm not a compiler
> writer. ;-)
It's not that GCC does not know how to solve this (since it used to
"work") but rather that the C++ standard states that it should not
perform the needed lookup since the source is somewhat ambiguous.
To quote the C++ standard (14.6.2/3)
"In the definition of a class or class template, if a base class depends
on a template-parameter, the base class
scope is not examined during unqualified name lookup either at the point
of definition of the class template
or member or during an instantiation of the class template or member."
Also, see the GCC bug that I linked in the previous bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24163
/Mikael
>
> Cheers,
> David
>
>>
>> Coleen
>>
>> On 11/4/2012 5:28 PM, David Holmes wrote:
>>> Hi Peter,
>>>
>>> I think we have lost some changes through the NPG integration. This
>>> code was updated by Mikael Gerdin under:
>>>
>>> 7172226: HotSpot fails to build with GCC 4.7 because of stricter c++
>>> argument dependent lookup
>>>
>>> http://hg.openjdk.java.net/jdk8/jdk8/hotspot/diff/a297b0e14605/src/share/vm/memory/binaryTreeDictionary.cpp
>>>
>>>
>>>
>>> but the NPG changes by Jon under
>>>
>>> 7045397: NPG: Add freelists to class loader arenas
>>>
>>> http://hg.openjdk.java.net/jdk8/jdk8/hotspot/rev/685df3c6f84b
>>>
>>> http://hg.openjdk.java.net/jdk8/jdk8/hotspot/diff/685df3c6f84b/src/share/vm/memory/binaryTreeDictionary.cpp
>>>
>>>
>>>
>>> seems to have undone those changes in part.
>>>
>>> The preferred fix was to add "using" directives rather than writing
>>> fully-qualified names.
>>>
>>> David
>>>
>>> On 5/11/2012 7:09 AM, Peter Levart wrote:
>>>> Hi,
>>>>
>>>> Current head of jdk8/hotspot repository (3790:4d37eb50b9b1) can not be
>>>> built with gcc 4.7.2.
>>>>
>>>> I had to make the following changes to compile with gcc 4.7.2 (on
>>>> linux):
>>>>
>>>>
>>>> diff -r 4d37eb50b9b1 src/share/vm/memory/binaryTreeDictionary.cpp
>>>> --- a/src/share/vm/memory/binaryTreeDictionary.cpp Thu Nov 01 14:11:16
>>>> 2012 -0700
>>>> +++ b/src/share/vm/memory/binaryTreeDictionary.cpp Sun Nov 04 22:07:29
>>>> 2012 +0100
>>>> @@ -239,7 +239,7 @@
>>>> } else {
>>>> if (nextTC == NULL) {
>>>> // Removing chunk at tail of list
>>>> - link_tail(prevFC);
>>>> + this->link_tail(prevFC);
>>>> }
>>>> // Chunk is interior to the list
>>>> prevFC->link_after(nextTC);
>>>> @@ -296,7 +296,7 @@
>>>>
>>>> Chunk_t* fc = tail();
>>>> fc->link_after(chunk);
>>>> - link_tail(chunk);
>>>> + this->link_tail(chunk);
>>>>
>>>> assert(!tail() || size() == tail()->size(), "Wrong sized chunk in
>>>> list");
>>>> FreeList_t<Chunk_t>::increment_count();
>>>> @@ -323,7 +323,7 @@
>>>> chunk->link_after(fc);
>>>> } else {
>>>> assert(tail() == NULL, "List is inconsistent");
>>>> - link_tail(chunk);
>>>> + this->link_tail(chunk);
>>>> }
>>>> head()->link_after(chunk);
>>>> assert(!head() || size() == head()->size(), "Wrong sized chunk in
>>>> list");
>>>> @@ -940,7 +940,7 @@
>>>> void do_tree(TreeList<Chunk_t, FreeList_t>* tl) {
>>>> if (tl != NULL) {
>>>> do_tree(tl->left());
>>>> - do_list(tl);
>>>> + this->do_list(tl);
>>>> do_tree(tl->right());
>>>> }
>>>> }
>>>> @@ -952,7 +952,7 @@
>>>> void do_tree(TreeList<Chunk_t, FreeList_t>* tl) {
>>>> if (tl != NULL) {
>>>> do_tree(tl->right());
>>>> - do_list(tl);
>>>> + this->do_list(tl);
>>>> do_tree(tl->left());
>>>> }
>>>> }
>>>> @@ -1008,7 +1008,7 @@
>>>> bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) {
>>>> if (tl != NULL) {
>>>> if (do_tree(tl->left())) return true;
>>>> - if (do_list(tl)) return true;
>>>> + if (this->do_list(tl)) return true;
>>>> if (do_tree(tl->right())) return true;
>>>> }
>>>> return false;
>>>> @@ -1022,7 +1022,7 @@
>>>> bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) {
>>>> if (tl != NULL) {
>>>> if (do_tree(tl->right())) return true;
>>>> - if (do_list(tl)) return true;
>>>> + if (this->do_list(tl)) return true;
>>>> if (do_tree(tl->left())) return true;
>>>> }
>>>> return false;
>>>>
>>>>
>>>>
>>>> Regards, Peter
>>>>
>>
--
Mikael Gerdin
Java SE VM SQE Stockholm
More information about the hotspot-runtime-dev
mailing list