public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66341] New: Some casts wrongly produce a lvalue
@ 2015-05-30  8:24 kp.lehrmann+gcc at gmail dot com
  2015-05-30 16:31 ` [Bug c/66341] " msebor at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kp.lehrmann+gcc at gmail dot com @ 2015-05-30  8:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66341

            Bug ID: 66341
           Summary: Some casts wrongly produce a lvalue
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kp.lehrmann+gcc at gmail dot com
  Target Milestone: ---

Created attachment 35653
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35653&action=edit
gcc compiles ok instead of producing a "error: lvalue required as left operand
of assignment"

Hello,

gcc (any version that I tried) allows some casts to produce a lvalue, whereas
"error: lvalue required as left operand of assignment" would be expected.

Basically, cast of the following form wrongly compile:

    struct B{ int *c;};
    struct A{ struct B b;};
    struct A  a;

    int d = 5;
    (int*)((struct A *)(&a)->b.c) = &d;

Note that if the first cast (int*) is replaced by a cast to any type but the
type of the member in struct B, the expected error message is produced.

For instance, 
    (char*)((struct A *)(&a)->b.c) = &d;
produce the expected error.

Best regards


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

end of thread, other threads:[~2023-03-23  1:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-30  8:24 [Bug c/66341] New: Some casts wrongly produce a lvalue kp.lehrmann+gcc at gmail dot com
2015-05-30 16:31 ` [Bug c/66341] " msebor at gcc dot gnu.org
2015-06-03 16:20 ` mpolacek at gcc dot gnu.org
2015-06-04  8:18 ` mpolacek at gcc dot gnu.org
2015-06-04  8:18 ` mpolacek at gcc dot gnu.org
2023-03-23  1:23 ` pinskia at gcc dot gnu.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).