Skip to content

Codebase incompatible with /Zc:strictStrings #4146

@CookiePLMonster

Description

@CookiePLMonster

For info on /Zc:strictStrings see:
https://msdn.microsoft.com/en-us/library/dn449508.aspx

By default, Visual Studio allows for nonstandard C++ behaviour by allowing to assign string literals to non-const qualified types. For example, this is not standard:

TCHAR *nbCharLabel = TEXT("Characters (without blanks): ");

Standard requires such literal is const, so by definition it should not be possible to assign them like this. It's more than likely an attempt to write to the value pointed to by nbCharLabel will cause access violation.

/Zc:strictStrings enforces VS compiler to follow standard behaviour. Thus, it may be feasible to enable this switch for all compilation options (it's not exposed to project settings in 2015/2017, so it needs to be manually added to Command Line tab. When done, code will refuse to compile, throwing lots of errors (sadly, some of them are in ScintillaComponent - is it fine to fix things in there from within Notepad++). However, it's safe to just correct them - as if the code was relying on non-constness of such literals already, we'd end up with a crash any time code attempts to write to it. Thus, the only places which are not going to be trivially fixable (by adding a const qualifier to parameters and variables) are potential bugs in the code.

EDIT:
#3918 seems to reference this issue - tagging @chcg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions