That statement IS nonsense. There are several ways that you can do that. Casting the literal to a char * is one way, but that doesn't change the fact that what is passed is a pointer to a string literal.
A string literal is pointed to by a const char *. There is no getting around that fact.
The function that you are passing the pointer to expects that, or it doesn't. There is no getting around that fact, either.
The language is not. Your interpretation of some code, and resulting behavior, is.I've been using C++ for more than 20 years.
Um... You are already contradicting yourself. Just a second ago you clearly (and correctly) stated that there is a way to get around that fact: casting it to `char *`. What gives?
In this case the fact is we are doing with third-party code from a repository (read: a code that we should not really modify) that suffers from this unfortunate problem.
But alas I've seen people who "used" the language for even longer periods of time, but... you know... never really cared to learn it properly.
You can't get around the fact that a string literal is pointed to by a const char *. You can pretend that a const char * is a char *, when passing the pointer to a function that expects a pointer to char BUT that doesn't actually intend to modify the char array pointed to.Trying to pretend that a const char * is a char *, when the function DOES actually modify the pointed to array is a recipe for disaster.
Nobody is trying to modify string literals here. I don't know why you keep bringing this up.
Since the function is trying to modify the value pointed to, the function should promise not to do that. THAT is what the discussion is about. Since it did not, then the discussion began to focus on how to get around that.