[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Improper warning when casting from pointer to non-const array to const



>Submitter-Id:	net
>Originator:	agthorr@barsoom.org
>Organization:	The Debian Project
>Confidential:	no
>Synopsis:	
>Severity:	non-critical
>Priority:	low
>Category:	c
>Class:		change-request
>Release:	3.2.1 (Debian) (Debian unstable)
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
host: i386-linux
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.2 20021212 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #126411.
  Please CC 126411@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/126411 ]
	

gcc generates a warning for the following test program, that I believe
is inappropriate.  The warning is that it cannot implicitly cast from
(foo *) to (const foo *).  This occurs when foo is an array type.  The
sample program compiles without warnings if you remove the "const"
keyword, or if you remove the [16] making foo an array.

This occurs in gcc 2.95.x upto gcc-3_3-branch, no check on HEAD

This is a problem for me since I normally compile with -Werror and
make rigorous use of const.  I can make explicit casts as a temporary
fix, but this makes my code ugly ;)

typedef char foo[16];

void bar (const foo *xyzzy)
{}

int main(void)
{
        foo bozz;
        bar (&bozz);
        
        return 0;
}


>How-To-Repeat:
	
>Fix:
	



Reply to: