RFR(M): 8068883: Remove disabling of warning "C4355: 'this' : used in base member initializer list"

Volker Simonis volker.simonis at gmail.com
Tue Jan 13 18:04:10 UTC 2015


Hi,

so here comes the change which re-enables the warning "C4355: 'this' :
used in base member initializer list".

http://cr.openjdk.java.net/~simonis/webrevs/2015/8068883/
https://bugs.openjdk.java.net/browse/JDK-8068883

This was previously discussed in the mail thread for "RFR(S): 8068739:
G1CollectorPolicy uses uninitialized field '_sigma' in the
constructor" (http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/2015-January/011743.html).

There are several places in the GC coding which disable the warning
Visual Studio warning "C4355: 'this' : used in base member initializer
list":

src/share/vm/gc_implementation/g1/concurrentMark.cpp:#pragma warning(
disable:4355 )
src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp:#pragma warning(
disable:4355 )
src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp:#pragma warning(
disable:4355 )
src/share/vm/gc_implementation/g1/satbQueue.cpp:#pragma warning( disable:4355 )
src/share/vm/gc_implementation/parNew/parNewGeneration.cpp:#pragma
warning( disable:4355 )
src/share/vm/gc_implementation/parNew/parNewGeneration.cpp:#pragma
warning( disable:4355 )

However this warning is reasonable and we've recently found a bug
which was caused by the usage of the incompletely initialized this
pointer in the initializer list (see issue 8068739 -
https://bugs.openjdk.java.net/browse/JDK-8068739).

Now that I've done this change I must confess that I'm not that
enthusiastic about it any more. The good thing is that I've checked
all the occurrences of "this" in initializer lists and non of them was
"dangerous" (i.e. they all just saved the value of the "this" pointer
into a field without calling any method on it or using any nonstatic
field through it).

Unfortunately, moving the corresponding field initializations from the
initializer list into the constructor body, required the creation of
several default constructors which is not that nice. On the other
side, I think the code got cleaner now and we are getting rid of the
pragmas which disabled the corresponding compiler warnings on Windows.
Notice that although the current implementation wasn't wrong, it still
handed over the this pointer from the initializer list several levels
of indirection down which makes it hard to detect from a first glance
if that usage is safe or not. But please judge yourself if it's worth
while doing this clean-up or not.

I've additionally also removed the Visual Studio compiler macro which
disable the warning "C4786:'identifier' : identifier was truncated to
'number' characters in the debug information." because as far as I
could see, this was only relevant up to Visual Studio 6.0 and I hope
nobody will ever compile the HotSpot with that compiler any more(see
http://support.microsoft.com/kb/195386).

Thank you and best regards,
Volker


More information about the hotspot-gc-dev mailing list