public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58235] New: Missing diagnostic on assignment to array in c89
@ 2013-08-23 22:32 olivier.gay at a3 dot epfl.ch
  2013-08-23 23:07 ` [Bug c/58235] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: olivier.gay at a3 dot epfl.ch @ 2013-08-23 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58235
           Summary: Missing diagnostic on assignment to array in c89
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olivier.gay at a3 dot epfl.ch

struct bla
{
    int x[1];
} s = {{0}};

struct bla foo(void)
{
    return s;
}

void bar(void)
{
    int c[1];
    c = foo().x;
}

gcc in c89 mode (-std=c89 -Wall -pedantic) does not issue a diagnostic for the
assignment to a non-modifiable lvalue in bar function. -std=c99 or -std=c11 do
issue the required diagnostic.


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
@ 2013-08-23 23:07 ` pinskia at gcc dot gnu.org
  2013-08-23 23:15 ` olivier.gay at a3 dot epfl.ch
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-08-23 23:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This seems correct: See also bug 461.  non-lvalue arrays do not decay to
pointers in C90/C89.


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
  2013-08-23 23:07 ` [Bug c/58235] " pinskia at gcc dot gnu.org
@ 2013-08-23 23:15 ` olivier.gay at a3 dot epfl.ch
  2013-08-24  0:16 ` farouk.jouti at live dot co.uk
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: olivier.gay at a3 dot epfl.ch @ 2013-08-23 23:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Olivier Gay <olivier.gay at a3 dot epfl.ch> ---
Still, constraint of assignment (c90, 6.3.16) requires the left operand of
assignment to be a modifiable lvalue. But c object array is not a modifiable
lvalue as arrays are not modifiable lvalues (6.2.2.1).


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
  2013-08-23 23:07 ` [Bug c/58235] " pinskia at gcc dot gnu.org
  2013-08-23 23:15 ` olivier.gay at a3 dot epfl.ch
@ 2013-08-24  0:16 ` farouk.jouti at live dot co.uk
  2013-08-24  0:21 ` farouk.jouti at live dot co.uk
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: farouk.jouti at live dot co.uk @ 2013-08-24  0:16 UTC (permalink / raw)
  To: gcc-bugs

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

farouk jouti <farouk.jouti at live dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |farouk.jouti at live dot co.uk

--- Comment #3 from farouk jouti <farouk.jouti at live dot co.uk> ---
http://stackoverflow.com/questions/18412094/a-legal-lvalue-array-is-it-possible/18413586?noredirect=1#18413586


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
                   ` (2 preceding siblings ...)
  2013-08-24  0:16 ` farouk.jouti at live dot co.uk
@ 2013-08-24  0:21 ` farouk.jouti at live dot co.uk
  2013-12-03  2:47 ` jsm28 at gcc dot gnu.org
  2013-12-03  2:48 ` jsm28 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: farouk.jouti at live dot co.uk @ 2013-08-24  0:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from farouk jouti <farouk.jouti at live dot co.uk> ---
the link contains all the necessary information about the bug (just check the
comments and answers) ;)


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
                   ` (3 preceding siblings ...)
  2013-08-24  0:21 ` farouk.jouti at live dot co.uk
@ 2013-12-03  2:47 ` jsm28 at gcc dot gnu.org
  2013-12-03  2:48 ` jsm28 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-12-03  2:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Author: jsm28
Date: Tue Dec  3 02:47:13 2013
New Revision: 205615

URL: http://gcc.gnu.org/viewcvs?rev=205615&root=gcc&view=rev
Log:
    PR c/58235
c:
    * c-typeck.c (build_modify_expr): Diagnose assignment to
    expression with array type.

testsuite:
    * gcc.dg/c90-array-lval-8.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/c90-array-lval-8.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/58235] Missing diagnostic on assignment to array in c89
  2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
                   ` (4 preceding siblings ...)
  2013-12-03  2:47 ` jsm28 at gcc dot gnu.org
@ 2013-12-03  2:48 ` jsm28 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-12-03  2:48 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #6 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 4.9.


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

end of thread, other threads:[~2013-12-03  2:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-23 22:32 [Bug c/58235] New: Missing diagnostic on assignment to array in c89 olivier.gay at a3 dot epfl.ch
2013-08-23 23:07 ` [Bug c/58235] " pinskia at gcc dot gnu.org
2013-08-23 23:15 ` olivier.gay at a3 dot epfl.ch
2013-08-24  0:16 ` farouk.jouti at live dot co.uk
2013-08-24  0:21 ` farouk.jouti at live dot co.uk
2013-12-03  2:47 ` jsm28 at gcc dot gnu.org
2013-12-03  2:48 ` jsm28 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).