code inspection clang-diagnostic-writable-strings not working propertly

for this code:

const char* test(const char* param)


    char* a = "test";              // get warning, correct.

    const char* b = "test";    // get warning, which should not

    const char* c = (const char*)"test";   // no warning

    return "test";   // get warning, which should not


test("param");    // get warning, which should not

test((const char*)"param"); // no warning


so according to this, is this by design?





Sorry, I can't reproduce this - clang-tidy only shows me one clang-diagnostic-writable-strings warning on this code and it's correct.

Which R++ version are you using? Could you please create a request in and attach a sample solution with this issue?



Sorry, I forgot to say, this will only reproduce in Visual Studio Linux Project.

I'm using Visual Studio Professional 2017 Version 15.7.3 and Resharper C++ 2018.1


Still can't reproduce even with a Linux project. It seems like const was defined to be empty - if you invoke "Go to declaration" on const, does anything happen?


"Go to declaration" on const is grey, which is disabled. so here const is a c++ keyword I think.


At least clang thinks that const is missing for some reason. Could you please send us this solution, I'll recheck with it.

Where does <cstdio> resolve to for you? On my VS project it goes to "Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\Linux\include\usr\include\c++\5\cstdio".


Also does it happen if you remove the include directives from your example?


Yes, when I remove the include directives, the problem is gone.

I'm using VS's Remote Headers IntelliSense Cache, when I delete the cache, [clang-diagnostic-writable-strings] warning is gone too.

So I think this is the problem.

When I remove the cache by deleteing the cache folder,  <cstdio> will be resolved to "Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\Linux\include\usr\include\c++\5\cstdio" (not just disable the cache in vs options, it will cause <cstdio> can not be resolved)

here is my cache detail:

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\x86_64-pc-linux-gnu\7.1.0\..\..\..\..\include\c++\7.1.0

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\x86_64-pc-linux-gnu\7.1.0\..\..\..\..\include\c++\7.1.0\x84_64-pc-linux-gnu

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\x86_64-pc-linux-gnu\7.1.0\..\..\..\..\include\c++\7.1.0\backward

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\x86_64-pc-linux-gnu\7.1.0\..\..\..\..\include\c++\7.1.0\include

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\x86_64-pc-linux-gnu\7.1.0\..\..\..\..\include\c++\7.1.0\include-fixed

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\usr\local\include

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\home\raven\bin\..\lib\gcc\..\..\include

C:\Users\Raven\AppData\Local\Microsoft\Linux\Header Cache\1.0\977886017\usr\include





Could you please archive the cached headers and attach them to We'll try to create a minimal repro.



Ok, I have uploaded an attachment.


Please sign in to leave a comment.