Bug#126411: gcc-3.0: Improper warning when casting from pointer to non-const array to const
Package: gcc-3.0
Version: 1:3.0.2-4
Severity: normal
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 also occurs in gcc 2.95.4.
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 ;)
-- Agthorr
------------------------------------------------------------------------
typedef char foo[16];
void bar (const foo *xyzzy)
{}
int main(void)
{
foo bozz;
bar (&bozz);
return 0;
}
------------------------------------------------------------------------
-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux eleutheromania 2.4.16 #1 Tue Dec 4 11:20:43 PST 2001 i686
Locale: LANG=C, LC_CTYPE=
Versions of packages gcc-3.0 depends on:
ii binutils 2.11.92.0.12.3-3 The GNU assembler, linker and bina
ii cpp-3.0 1:3.0.2-4 The GNU C preprocessor.
ii gcc-3.0-base 1:3.0.2-4 The GNU Compiler Collection (base
ii libc6 2.2.4-7 GNU C Library: Shared libraries an
ii libgcc1 1:3.0.2-4 GCC support library.
Reply to: