public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/9070: Improper warning when casting from pointer to non-const array to const
@ 2002-12-27 14:16 Matthias Klose
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Klose @ 2002-12-27 14:16 UTC (permalink / raw)
  To: gcc-gnats, debian-gcc


>Number:         9070
>Category:       c
>Synopsis:       Improper warning when casting from pointer to non-const array to const
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 27 14:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     agthorr@barsoom.org
>Release:        3.2.1 (Debian) (Debian unstable)
>Organization:
The Debian Project
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
host: i386-linux
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.2 20021212 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #126411.
  Please CC 126411@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/126411 ]
	

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 occurs in gcc 2.95.x upto gcc-3_3-branch, no check on HEAD

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 ;)

typedef char foo[16];

void bar (const foo *xyzzy)
{}

int main(void)
{
        foo bozz;
        bar (&bozz);
        
        return 0;
}


>How-To-Repeat:
	
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/9070: Improper warning when casting from pointer to non-const array to const
@ 2003-01-11 11:16 doko
  0 siblings, 0 replies; 3+ messages in thread
From: doko @ 2003-01-11 11:16 UTC (permalink / raw)
  To: 126411, agthorr, gcc-bugs, gcc-prs, nobody

Synopsis: Improper warning when casting from pointer to non-const array to const

State-Changed-From-To: open->closed
State-Changed-By: doko
State-Changed-When: Sat Jan 11 03:16:55 2003
State-Changed-Why:
    not a bug

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9070


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/9070: Improper warning when casting from pointer to non-const array to const
@ 2002-12-27 14:46 Joseph S. Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph S. Myers @ 2002-12-27 14:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/9070; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: <126411@bugs.debian.org>
Cc: <gcc-gnats@gcc.gnu.org>,  <debian-gcc@lists.debian.org>, 
     <gcc-bugs@gcc.gnu.org>,  <agthorr@barsoom.org>
Subject: Re: c/9070: Improper warning when casting from pointer to non-const
 array to const
Date: Fri, 27 Dec 2002 22:38:40 +0000 (GMT)

 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.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-11 11:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-27 14:16 c/9070: Improper warning when casting from pointer to non-const array to const Matthias Klose
2002-12-27 14:46 Joseph S. Myers
2003-01-11 11:16 doko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).