This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/40911] New: Strange type incompatibility is field initialization (type pointer to array)
- From: "olivier dot lobry at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jul 2009 10:03:35 -0000
- Subject: [Bug c/40911] New: Strange type incompatibility is field initialization (type pointer to array)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compiling file test.c using command: gcc -c test.c -o test.o
<<<< test.c
/* 01 */ int foo[] = { 0 };
/* 02 */
/* 03 */ int (*bar)[] = &foo;
/* 04 */
/* 05 */ struct {
/* 06 */ int (*bar)[];
/* 07 */ } myStruct = {
/* 08 */ .bar = &foo
/* 09 */ };
/* 10 */
>>> test.c
raises the following warning:
test.c:9: warning: initialization from incompatible pointer type
I don't understand why types are not compatible and what is strange is that
line #03 does not raise the same warning though variable 'bar' and field
'myStruct.bar' have excatly the same types and initialized with the same value.
===========
gcc version info
===========
$ avr-gcc --version
avr-gcc (GCC) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../configure --prefix=/usr/local/CrossPack-AVR-20090415
--disable-dependency-tracking --disable-nls --disable-werror --target=avr
--enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
Thread model: single
gcc version 4.3.2 (GCC)
I have the same problem with other gcc versions, like :
==========
os x gcc (4.2.1)
==========
$ gcc-4.2 --version
i686-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc-4.2 -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc_42/gcc_42-5566~1/src/configure --disable-checking
--enable-werror --prefix=/usr --mandir=/usr/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin9 --with-gxx-include-dir=/usr/include/c++/4.0.0
--host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5566)
============
arm-elf-gcc (4.1.0)
============
$ arm-elf-gcc --version
arm-elf-gcc (GCC) 4.1.0
Copyright © 2006 Free Software Foundation, Inc.
Ce logiciel est libre; voir les sources pour les conditions de copie. Il n'y a
PAS
GARANTIE; ni implicite pour le MARCHANDAGE ou pour un BUT PARTICULIER.
$ arm-elf-gcc -v
Utilisation des specs internes.
Target: arm-elf
Configuré avec: ./configure --target=arm-elf --prefix=/usr/local/arm
--enable-interwork --enable-multilib --enable-languages=c,c++ --with-newlib
--with-headers=../../src/newlib-1.14.0/newlib/libc/include
Modèle de thread: single
version gcc 4.1.0
==========
avr-gcc (4.2.0)
==========
$ avr-gcc --version
avr-gcc (GCC) 4.2.0 20060701 (experimental)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../configure --prefix=/Users/lobry/avr/avr-toolchain
--target=avr --enable-languages=c --disable-nls --disable-libssp
Thread model: single
gcc version 4.2.0 20060701 (experimental)
Best regards,
Olivier
--
Summary: Strange type incompatibility is field initialization
(type pointer to array)
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: olivier dot lobry at free dot fr
GCC build triplet: i386-apple-darwin8.10.1
GCC host triplet: i386-apple-darwin8.10.1
GCC target triplet: avr-unknown-none
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40911