JDK-8196884 : VS2017 Multiple Type Cast Conversion Compilation Errors
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2018-02-06
  • Updated: 2020-04-12
  • Resolved: 2018-02-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 7 JDK 8
11 b03Fixed 7u211Fixed 8u192Fixed
Related Reports
Relates :  
Relates :  
Description
abstractCompiler.cpp
<directory>\open\src\hotspot\share\asm/codeBuffer.hpp(115): error C2220: warning treated as error - no 'object' file generated
<directory>\open\src\hotspot\share\asm/codeBuffer.hpp(115): warning C4312: 'type cast': conversion from 'const long' to 'address' of greater size
Comments
We could even add a macro in global_definitions.hpp #define BAD_PTR ((intptr_t)0xdeadbeef)
14-02-2018

I wouldn't bother with the WINDOWS_ONLY part, just cast to intptr_t then to actual pointer type.
14-02-2018

diff -r 11920d5d14a8 src/hotspot/share/opto/idealGraphPrinter.cpp --- a/src/hotspot/share/opto/idealGraphPrinter.cpp Wed Jan 31 17:43:46 2018 -0800 +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp Tue Feb 13 14:09:05 2018 -0500 @@ -602,7 +602,7 @@ } #endif - if (_chaitin && _chaitin != (PhaseChaitin *)0xdeadbeef) { + if (_chaitin && _chaitin != (PhaseChaitin *)(WINDOWS_ONLY((intptr_t))0xdeadbeef)) { buffer[0] = 0; _chaitin->dump_register(node, buffer); print_prop("reg", buffer);
13-02-2018

diff -r 11920d5d14a8 src/hotspot/share/opto/gcm.cpp --- a/src/hotspot/share/opto/gcm.cpp Wed Jan 31 17:43:46 2018 -0800 +++ b/src/hotspot/share/opto/gcm.cpp Tue Feb 13 14:08:28 2018 -0500 @@ -1486,7 +1486,7 @@ } #endif // Dead. - _node_latency = (GrowableArray<uint> *)0xdeadbeef; + _node_latency = (GrowableArray<uint> *)(WINDOWS_ONLY((intptr_t))0xdeadbeef); } bool PhaseCFG::do_global_code_motion() {
13-02-2018

compile.cpp <directory>/open/src/hotspot/share/opto/compile.cpp(2452): error C2220: warning treated as error - no 'object' file generated <directory>/open/src/hotspot/share/opto/compile.cpp(2452): warning C4312: 'type cast': conversion from 'unsigned int' to 'PhaseCFG *' of greater size <directory>/open/src/hotspot/share/opto/compile.cpp(2453): warning C4312: 'type cast': conversion from 'unsigned int' to 'PhaseChaitin *' of greater size diff -r 11920d5d14a8 src/hotspot/share/opto/compile.cpp --- a/src/hotspot/share/opto/compile.cpp Wed Jan 31 17:43:46 2018 -0800 +++ b/src/hotspot/share/opto/compile.cpp Thu Feb 08 15:46:46 2018 -0500 @@ -2449,8 +2449,8 @@ print_method(PHASE_FINAL_CODE); // He's dead, Jim. - _cfg = (PhaseCFG*)0xdeadbeef; - _regalloc = (PhaseChaitin*)0xdeadbeef; + _cfg = (PhaseCFG*)((intptr_t)0xdeadbeef); + _regalloc = (PhaseChaitin*)((intptr_t)0xdeadbeef); }
08-02-2018

Another instance: diff -r 11920d5d14a8 src/hotspot/share/opto/buildOopMap.cpp --- a/src/hotspot/share/opto/buildOopMap.cpp Wed Jan 31 17:43:46 2018 -0800 +++ b/src/hotspot/share/opto/buildOopMap.cpp Thu Feb 08 15:01:40 2018 -0500 @@ -618,7 +618,7 @@ // last block as his only undone child, we can move the OopFlow from the // pred to this block. Otherwise we have to grab a new OopFlow. OopFlow *flow = NULL; // Flag for finding optimized flow - Block *pred = (Block*)0xdeadbeef; + Block *pred = (Block*)((intptr_t)0xdeadbeef); // Scan this block's preds to find a done predecessor for (uint j = 1; j < b->num_preds(); j++) { Block* p = _cfg->get_block_for_node(b->pred(j));
08-02-2018

I suggest leaving badOopVal alone for this change. I noticed it while looking at that comment and did a bit of investigation. I'm going to file an RFE to delete it entirely; it's almost unused, and I think what uses exist are questionable.
07-02-2018

+1 to Kim's comment. "long" is typically mistakenly used assuming either ILP32 or LP64 programming models, and expected to adapt based on 32-bit or 64-bit. That breaks on Windows where it is always 32-bit. So intptr_t is the best choice - particularly for an Address. I'd suggest also changing const long badOopVal though it's unclear whether this is expected to be an "address" or not. If so then again intptr_t.
07-02-2018

intptr_t would be a better choice than int64_t, to avoid unintended breakage of 32bit platforms.
06-02-2018

In hotspot/share/utilities/globalDefinitions.hpp, change: // Special constants for debugging const jint badInt = -3; // generic "bad int" value -const long badAddressVal = -2; // generic "bad address" value +const int64_t badAddressVal = -2; // generic "bad address" value const long badOopVal = -1; // generic "bad oop" value const intptr_t badHeapOopVal = (intptr_t) CONST64(0x2BAD4B0BBAADBABE); // value used to zap heap after GC const int badStackSegVal = 0xCA; // value used to zap stack segments
06-02-2018