[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#126411: marked as done (gcc-3.0: Improper warning when casting from pointer to non-const array to const)



Your message dated Sat, 11 Jan 2003 12:18:00 +0100
with message-id <15903.64872.815380.390059@gargle.gargle.HOWL>
and subject line Not a bug: Improper warning when casting from pointer to non-const array to const
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 25 Dec 2001 06:14:32 +0000
>From agthorr@barsoom.org Tue Dec 25 00:14:32 2001
Return-path: <agthorr@barsoom.org>
Received: from cx568534-a.lncln1.ri.home.com (eleutheromania.barsoom.org) [65.15.34.25] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 16IkrA-0006m4-00; Tue, 25 Dec 2001 00:14:32 -0600
Received: from agthorr by eleutheromania.barsoom.org with local (Exim 3.32 #1 (Debian))
	id 16Ikhr-0004BP-00; Mon, 24 Dec 2001 22:04:55 -0800
From: Agthorr <agthorr@barsoom.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: gcc-3.0: Improper warning when casting from pointer to non-const array to const
X-Reportbug-Version: 1.36
X-Mailer: reportbug 1.36
Date: Mon, 24 Dec 2001 22:04:54 -0800
Message-Id: <E16Ikhr-0004BP-00@eleutheromania.barsoom.org>
Delivered-To: submit@bugs.debian.org

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.


---------------------------------------
Received: (at 126411-done) by bugs.debian.org; 11 Jan 2003 11:19:05 +0000
>From doko@cs.tu-berlin.de Sat Jan 11 05:19:04 2003
Return-path: <doko@cs.tu-berlin.de>
Received: from mail.cs.tu-berlin.de [130.149.17.13] (root)
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 18XJfM-00083j-00; Sat, 11 Jan 2003 05:19:04 -0600
Received: from bolero.cs.tu-berlin.de (daemon@bolero.cs.tu-berlin.de [130.149.19.1])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id MAA15976
	for <126411-done@bugs.debian.org>; Sat, 11 Jan 2003 12:18:01 +0100 (MET)
Received: (from doko@localhost)
	by bolero.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id h0BBI0C04727;
	Sat, 11 Jan 2003 12:18:00 +0100 (MET)
From: Matthias Klose <doko@cs.tu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <15903.64872.815380.390059@gargle.gargle.HOWL>
Date: Sat, 11 Jan 2003 12:18:00 +0100
To: <126411-done@bugs.debian.org>
Subject: Not a bug: Improper warning when casting from pointer to non-const
 array to const
In-Reply-To: <Pine.LNX.4.33.0212272234360.24757-100000@kern.srcf.societies.cam.ac.uk>
References: <E18S2js-0003Xk-00@tango.net.local>
	<Pine.LNX.4.33.0212272234360.24757-100000@kern.srcf.societies.cam.ac.uk>
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
Delivered-To: 126411-done@bugs.debian.org
X-Spam-Status: No, hits=-8.2 required=5.0
	tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01
	version=2.41
X-Spam-Level: 

not a bug. closing the report.

Joseph S. Myers writes:
> On Fri, 27 Dec 2002, Matthias Klose wrote:
> 
> > 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.
> 
> It is an assignment from "pointer to array[16] of char" to "pointer to 
> array[16] of const char" rather than to "pointer to const array[16] of 
> char", by virtue of the requirement (6.7.3#8 in C99) that a type qualifier 
> applied to an array type applies instead to the element type.  Thus the 
> case of 6.5.16.1#1 that would be matched in the case of pointers to 
> nonarray types adding qualifiers is not matched, thus the warning.



Reply to: