public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27697]  New: incorrect warning about constness of pointer to an array in a const struct
@ 2006-05-21  9:20 fischer at td dot mw dot tum dot de
  2006-05-21  9:31 ` [Bug c/27697] " fischer at td dot mw dot tum dot de
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: fischer at td dot mw dot tum dot de @ 2006-05-21  9:20 UTC (permalink / raw)
  To: gcc-bugs

In this snippet of code:

struct foo {
  int x[2][10];
};

void f(void)
{
  const struct foo bar;
  const int (*baz)[10] = bar.x; /* should be ok */
  int (*qoox)[10] = bar.x; /* should warn */

  bar.x[0][1] = 23; /* error: asignment to const */
  (*qoox)[1] = 23;
}

bar is const, so bar.x is (const int *), so an assignment to (const int *)
should be ok, while an assignment to (int *) violates the type constraints (all
according to 6.7.3 in the Standard).

in gcc 4.1.0, the behaviour is reversed: assignment to (int *) goes unnoticed
while assignment to (const int *) issues an "incompatible pointer" warning.


-- 
           Summary: incorrect warning about constness of pointer to an array
                    in a const struct
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fischer at td dot mw dot tum dot de
 GCC build triplet: i586-suse-linux
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


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


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

end of thread, other threads:[~2007-02-03 17:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-21  9:20 [Bug c/27697] New: incorrect warning about constness of pointer to an array in a const struct fischer at td dot mw dot tum dot de
2006-05-21  9:31 ` [Bug c/27697] " fischer at td dot mw dot tum dot de
2006-05-21 16:15 ` [Bug c/27697] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-05-21 23:17 ` neil at daikokuya dot co dot uk
2006-05-21 23:53 ` jsm28 at gcc dot gnu dot org
2006-06-04 19:20 ` mmitchel at gcc dot gnu dot org
2006-07-17  3:42 ` mmitchel at gcc dot gnu dot org
2006-08-16 17:18 ` jsm28 at gcc dot gnu dot org
2006-08-16 23:11 ` jsm28 at gcc dot gnu dot org
2006-08-16 23:12 ` jsm28 at gcc dot gnu dot org
2006-08-17 13:02 ` [Bug c/27697] [4.0 " brett dot albertson at stratech dot com
2006-08-26  0:11 ` jsm28 at gcc dot gnu dot org
2007-02-03 17:18 ` gdr at gcc dot gnu dot org

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