This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16602] New: Spurious warnings about pointer to array -> const pointer to array conversion


/* 
  This piece of code will trigger the warning "passing arg 1 of `name' from 
  incompatible pointer type" on lines 24, 25 and 26, but it should not, 
  because the pointers are in fact compatible. To prove the compatibility 
  comment out the "[8]" at line 9 and recompile; the warnings will disappear. 
  The warnings also disappear if the "const" from the OSHSAddrToBinIPv4() 
  declaration is removed; I guess that the "const" is doing problems. 
*/ 
 
typedef int THostAddr[8]; 
 
typedef struct { 
  char Command; 
  THostAddr Host; 
  int Port; 
} TOpenTCPClientCommand; 
 
static void OSHSAddrToBinIPv4(const THostAddr *Host) 
{ 
  THostAddr *MyHost; 
  TOpenTCPClientCommand P; 
  TOpenTCPClientCommand *Packet; 
 
  OSHSAddrToBinIPv4(MyHost); 
  OSHSAddrToBinIPv4(&P.Host); 
  OSHSAddrToBinIPv4(&Packet->Host); 
} 
 
/* 
  - Tested with gcc 3.2.2 on Mandrake GNU/Linux 9.1 ("bamboo") 
    (kernel 2.4.21-0.13mdk) on an i686 
  - Fails also with gcc 3.5.0 (experimental 17072004) on the same machine 
  - There is no bug when pointers to a structure or union are involved. 
*/

-- 
           Summary: Spurious warnings about pointer to array -> const
                    pointer to array conversion
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jozef dot behran at krs dot sk
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16602


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]