[Bug c/33076] New: Warning when passing a pointer to a const array to a function that expects a pointer to a non-cast one
martin dot ferrari at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 15 03:45:00 GMT 2007
Sorry if I'm misunderstanding something or this is a FAQ, but I couldn't find
any reference, except for a unanswered mail with the same problem from 2000 at
http://gcc.gnu.org/ml/gcc-bugs/2000-10/msg00337.html (and I don't find it in
bugzilla either). The code looks semantically correct to me, the function
declares that it won't touch the data and I'm passing a non-const data. If the
typecast is not to an array, the warning goes away.
Thanks.
Build options:
../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Command line:
$ gcc -c /home/martin/test.c
/home/martin/test.c: In function ÂbarÂ:
/home/martin/test.c:8: warning: passing argument 1 of Âfoo from incompatible
pointer type
Code:
typedef int caca[3];
void foo (const caca* p);
void bar(caca *c) {
foo(c);
}
--
Summary: Warning when passing a pointer to a const array to a
function that expects a pointer to a non-cast one
Product: gcc
Version: 4.1.3
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: martin dot ferrari at gmail dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33076
More information about the Gcc-bugs
mailing list