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/16895] New: incorrect warning when const ** parameter passed from non-const ** argument


Incorrect "passing arg # of 'func' from incompatible pointer type" warning when
a char ** argument is passed to a function defined with a const char **
parameter, but a char * argument passed to a function defined with a const char
* parameter is correctly accepted as having a compatible pointer type. The extra
level of indirection in the type seems to be causing problems for the type checker. 

messages: (file name elided)
.c: In function `main':
.c:20: warning: passing arg 2 of `getargs' from incompatible pointer type
.c:20: warning: passing arg 4 of `getargs' from incompatible pointer type

command: gcc -Wall -W incompatible_pointer.c

program:
#include <stdio.h>					/*  1 */
							/*  2 */
static const char *					/*  3 */
getargs( FILE **inpfp, const char **inpfn,		/*  4 */
		const char *inpfm, const char **argv)	/*  5 */
{
						/*  6 */
    *inpfp = stdin;					/*  7 */
    *inpfn = *argv;					/*  8 */
							/*  9 */
    return inpfm;					/* 10 */
}
						/* 11 */
							/* 12 */
int
						/* 13 */
main( int argc, char *argv[])				/* 14 */
{
						/* 15 */
    FILE *inpfp	= stdin;				/* 16 */
    char *inpfn	= "-";					/* 17 */
    char *inpfm	= "r";					/* 18 */
							/* 19 */
    getargs( &inpfp, &inpfn, inpfm, argv);		/* 20 */
							/* 21 */
    return argc;					/* 22 */
}
						/* 23 */

-- 
           Summary: incorrect warning when const ** parameter passed from
                    non-const ** argument
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Brian dot Inglis at SystematicSw dot ab dot ca
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-msdosdjgpp
  GCC host triplet: i386-pc-msdosdjgpp
GCC target triplet: i386-pc-msdosdjgpp


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


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