------- Comment #11 from bangerth at dealii dot org  2007-08-20 14:56 -------
(In reply to comment #10)
> I now think that Andrew is right and that PR33086 and this one are INVALID.
> 'const' does not mean read-only in C++ at all, and much less in C. atoi(const
> char *) could always initialize buf[].

Uh, no, it can't. If it did (by casting away the 'const' from its argument
and then writing into the array), this would lead to a segfault:
-------------
const char a[3] = "10";
int main () {
  return atoi (a);
}
-------------
The reason being that compilers will typically place 'a' into a read-only
memory section.

Passing an uninitialized object as a const reference or pointer is a bad
idea in C++ and should get a warning as a rule. I can't see reasons that would
warrant exceptions from this rule.

W.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10138

Reply via email to