Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Aug 2000 13:03:35 +1000 (EST)
From:      marka@nominum.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   gnu/20767: gcc const produces invalid warning
Message-ID:  <200008220303.NAA57805@drugs.dv.isc.org>

next in thread | raw e-mail | index | archive | help

>Number:         20767
>Category:       gnu
>Synopsis:       gcc const produces invalid warning
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 21 20:10:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Mark Andrews
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
Nominum
>Environment:

FreeBSD drugs.dv.isc.org 4.1-STABLE FreeBSD 4.1-STABLE #0: Fri Aug 18 13:53:08 EST 2000     marka@drugs.dv.isc.org:/usr/obj/usr/src/sys/DRUGS  i386

Using builtin specs.
gcc version 2.95.2 19991024 (release)

>Description:

	gcc incorrectly reports 'incompatible pointer type' when function
	is declared with 'const pointer to const pointer' arguement and is
	just passed pointer to pointer.

	Also generates error with 'const pointer to pointer' and 'pointer to
	const pointer', i.e. removing either of the consts still generates
	the warning.

>How-To-Repeat:

% cc xx.c
xx.c: In function `main':
xx.c:22: warning: passing arg 1 of `f' from incompatible pointer type

#include <stdio.h>

static const char *foo[] = { "test", NULL };

static int
f(const char * const *args) {
	int i, j, k;

	k = 0;
	for  (i = 0; args[i] != NULL; i++)
		for (j = 0; args[i][j] != '\0'; j++)
			k += args[i][j];
	return (k);
}

int
main(int argc, char **argv) {
	int i;
	
	i = f(foo);
	printf("%d\n", i); 
	i = f(argv);		/* This should not generate a warning! */
	printf("%d\n", i); 
	return (0);
}

>Fix:



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008220303.NAA57805>