[PATCH] Fix some assignments of string literals to non-const char*

David Holmes david.holmes at oracle.com
Tue May 14 07:49:22 UTC 2019


Thanks Thomas. My testing passed so I'll push this in the morning.

David
-----

On 14/05/2019 5:12 pm, Thomas Stüfe wrote:
> This looks fine.
> 
> Cheers, Thomas
> 
> On Tue, May 14, 2019 at 6:45 AM David Holmes <david.holmes at oracle.com 
> <mailto:david.holmes at oracle.com>> wrote:
> 
>     Hi Andrew,
> 
>     Thanks for the report and patch. We just had something very similar go
>     through for gcc 9 on non-Windows. :) Interesting gcc didn't complain
>     about the code in attachListener.hpp.
> 
>     I've filed:
> 
>     https://bugs.openjdk.java.net/browse/JDK-8223810
> 
>     and I will sponsor this for you. I've posted a webrev here:
> 
>     http://cr.openjdk.java.net/~dholmes/8223810/webrev/
> 
>     and am running the patch through our build.
> 
>     Thanks,
>     David
> 
>     On 14/05/2019 10:21 am, Andrew Luo wrote:
>      > I've been trying to get the JDK to compile with the new
>     /permissive- switch in VS2017
>     (https://devblogs.microsoft.com/cppblog/permissive-switch/) however
>     there have been a few issues in various parts of the code.  There
>     are a few issues in the hotspot code where we attempt to assign
>     string literals to char* (non-const) variables (unnecessarily).  I
>     took some time to fix some of these and attached a patch.  Let me
>     know if you have any comments/feedback.
>      >
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/test/hotspot/gtest/gtestMain.cpp(234):
>     error C2440: 'initializing': cannot convert from 'const char [19]'
>     to 'char *'
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/test/hotspot/gtest/gtestMain.cpp(234):
>     note: Conversion from string literal loses const qualifier (see
>     /Zc:strictStrings)
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/src/hotspot/os/windows/attachListener_windows.cpp(152):
>     error C2664: 'AttachOperation::AttachOperation(AttachOperation &&)':
>     cannot convert argument 1 from 'const char [9]' to 'char *'
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/src/hotspot/os/windows/attachListener_windows.cpp(152):
>     note: Conversion from string literal loses const qualifier (see
>     /Zc:strictStrings)
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/src/hotspot/os/windows/os_windows.cpp(204):
>     error C2440: 'initializing': cannot convert from 'const char [5]' to
>     'char *'
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/src/hotspot/os/windows/os_windows.cpp(204):
>     note: Conversion from string literal loses const qualifier (see
>     /Zc:strictStrings)
>      >
>     c:/Users/Andrew/Documents/mercurial/openjdk/jdk/src/hotspot/os/windows/os_windows.cpp(2214):
>     error C2440: 'initializing': ...
>      >
>      > Thanks,
>      >
>      > -Andrew
>      >
> 


More information about the hotspot-dev mailing list