RFR: 8281525: Enable Zc:strictStrings flag in Visual Studio build [v2]

Daniel Jeliński djelinski at openjdk.java.net
Tue Feb 22 16:43:28 UTC 2022


> Please review this PR that enables [Zc:strictStrings](https://docs.microsoft.com/en-us/cpp/build/reference/zc-strictstrings-disable-string-literal-type-conversion?view=msvc-170) compiler flag, which makes assigning a string literal to a non-const pointer a compile-time error.
> 
> This type of assignment is [disallowed by C++ standard since C++11](https://en.cppreference.com/w/cpp/language/string_literal). Writing to a string literal through a non-const pointer [produces a run-time error](https://docs.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp?view=msvc-170#microsoft-specific-1).
> 
> The included code changes are trivial; I added `const` keyword to variable and parameter declarations where needed, and added explicit casts to non-const pointers where adding `const` was not feasible.
> 
> I verified that the build passes both with and without `--enable-debug`, both with VS2017 and VS2019.

Daniel Jeliński has updated the pull request incrementally with one additional commit since the last revision:

  Move strictStrings to toolchain_cflags

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7565/files
  - new: https://git.openjdk.java.net/jdk/pull/7565/files/fe18b41d..0cfbb165

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7565&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7565&range=00-01

  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7565.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7565/head:pull/7565

PR: https://git.openjdk.java.net/jdk/pull/7565



More information about the security-dev mailing list