[vsipl++] [patch] CBE split-complex vmmul

Mark Mitchell mark at codesourcery.com
Thu Oct 2 20:47:16 UTC 2008


Stefan Seefeld wrote:

> * Compiling this and similar code with GCC 4.3 results in warnings
> related to conversion from char const* to char* (the assignment of
> string literals to argv)

That is indeed deprecated.  It was grandfathered in for compatibility
back to K&R C, but, obviously, string literals are const, so assignments
from "char const *" to "char *" require a cast -- and you'd better be
sure nobody is going to try to modify the string, as that will cause a SEGV.

I generally declare argv as:

  const char *argv[]

because you generally can't expect to change the strings in argv.
(Remember that they're coming from the OS via black magic; who knows
where they live.)  You can, however, expect to change the array
elements.  So:

  argv[1] = "foo"

is sensible, but:

  argv[1][3] = 'a'

is weird.

FWIW,

-- 
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713



More information about the vsipl++ mailing list