public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement)
@ 2011-05-23 10:49 kari.nurmela at stonesoft dot com
  2011-05-23 11:53 ` [Bug c/49120] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kari.nurmela at stonesoft dot com @ 2011-05-23 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: bogus "value computed is not used" warning
                    (variable-length array in compound statement)
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kari.nurmela@stonesoft.com


When declaring a variable-length array in the beginning of a compound
statement, so that the length expression contains at least one operator,
the warning "value computed is not used" is incorrectly given for the computed
length of the array (with -Wall). For example:

~$ cat kok1.c
int main(void)
{
    int foo = 1;
    ({
        char bar[foo + 1]; /* <==== */
        bar[0] = 0;
    });
    return 0;
}
~$ gcc-4.5 -Wall kok1.c -o kok1
kok1.c: In function ‘main’:
kok1.c:5:22: warning: value computed is not used
~$ gcc-4.5 --version
gcc-4.5 (Ubuntu/Linaro 4.5.1-7ubuntu2) 4.5.1
...

If the compound statement is replaced with a block in this example, the warning
goes away:

~$ cat kok2.c
int main(void)
{
    int foo = 1;
    {
        char bar[foo + 1];
        bar[0] = 0;
    }
    return 0;
}
~$ gcc-4.5 -Wall kok2.c -o kok2
~$

In gcc 4.4 the bogus warning does not appear:

~$ gcc-4.4 -Wall kok1.c -o kok1
~$ gcc-4.4 --version
gcc-4.4 (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
...


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

* [Bug c/49120] [4.5/4.6/4.7 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
@ 2011-05-23 11:53 ` rguenth at gcc dot gnu.org
  2011-05-23 11:58 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-23 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.4.5
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2011.05.23 10:54:25
     Ever Confirmed|0                           |1
            Summary|bogus "value computed is    |[4.5/4.6/4.7 Regression]
                   |not used" warning           |bogus "value computed is
                   |(variable-length array in   |not used" warning
                   |compound statement)         |(variable-length array in
                   |                            |compound statement)
   Target Milestone|---                         |4.5.4
      Known to fail|                            |4.5.3, 4.6.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-23 10:54:25 UTC ---
Confirmed.


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

* [Bug c/49120] [4.5/4.6/4.7 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
  2011-05-23 11:53 ` [Bug c/49120] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
@ 2011-05-23 11:58 ` jakub at gcc dot gnu.org
  2011-05-23 13:14 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-23 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-23 11:39:10 UTC ---
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145254


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

* [Bug c/49120] [4.5/4.6/4.7 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
  2011-05-23 11:53 ` [Bug c/49120] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
  2011-05-23 11:58 ` jakub at gcc dot gnu.org
@ 2011-05-23 13:14 ` jakub at gcc dot gnu.org
  2011-05-23 18:18 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-23 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-23 12:31:25 UTC ---
Created attachment 24335
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24335
gcc46-pr49120.patch

Untested fix.


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

* [Bug c/49120] [4.5/4.6/4.7 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
                   ` (2 preceding siblings ...)
  2011-05-23 13:14 ` jakub at gcc dot gnu.org
@ 2011-05-23 18:18 ` jakub at gcc dot gnu.org
  2011-05-23 18:35 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-23 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-23 18:02:08 UTC ---
Author: jakub
Date: Mon May 23 18:02:03 2011
New Revision: 174081

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174081
Log:
    PR c/49120
    * c-decl.c (start_decl): Convert expr to void_type_node.

    * gcc.dg/pr49120.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr49120.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/49120] [4.5/4.6/4.7 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
                   ` (3 preceding siblings ...)
  2011-05-23 18:18 ` jakub at gcc dot gnu.org
@ 2011-05-23 18:35 ` jakub at gcc dot gnu.org
  2011-05-23 18:55 ` [Bug c/49120] [4.5 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-23 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-23 18:03:35 UTC ---
Author: jakub
Date: Mon May 23 18:03:31 2011
New Revision: 174082

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174082
Log:
    PR c/49120
    * c-decl.c (start_decl): Convert expr to void_type_node.

    * gcc.dg/pr49120.c: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr49120.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/c-decl.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c/49120] [4.5 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
                   ` (4 preceding siblings ...)
  2011-05-23 18:35 ` jakub at gcc dot gnu.org
@ 2011-05-23 18:55 ` jakub at gcc dot gnu.org
  2011-07-19 12:51 ` jakub at gcc dot gnu.org
  2011-07-19 13:42 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-23 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.6.1, 4.7.0
            Summary|[4.5/4.6/4.7 Regression]    |[4.5 Regression] bogus
                   |bogus "value computed is    |"value computed is not
                   |not used" warning           |used" warning
                   |(variable-length array in   |(variable-length array in
                   |compound statement)         |compound statement)

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-23 18:17:58 UTC ---
Fixed for 4.6+ so far.


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

* [Bug c/49120] [4.5 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
                   ` (5 preceding siblings ...)
  2011-05-23 18:55 ` [Bug c/49120] [4.5 " jakub at gcc dot gnu.org
@ 2011-07-19 12:51 ` jakub at gcc dot gnu.org
  2011-07-19 13:42 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-19 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-19 12:48:54 UTC ---
Author: jakub
Date: Tue Jul 19 12:48:50 2011
New Revision: 176450

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176450
Log:
    Backport from mainline
    2011-05-23  Jakub Jelinek  <jakub@redhat.com>

    PR c/49120
    * c-decl.c (start_decl): Convert expr to void_type_node.

    * gcc.dg/pr49120.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr49120.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/c-decl.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug c/49120] [4.5 Regression] bogus "value computed is not used" warning (variable-length array in compound statement)
  2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
                   ` (6 preceding siblings ...)
  2011-07-19 12:51 ` jakub at gcc dot gnu.org
@ 2011-07-19 13:42 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-19 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-19 13:42:12 UTC ---
Fixed.


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

end of thread, other threads:[~2011-07-19 13:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 10:49 [Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement) kari.nurmela at stonesoft dot com
2011-05-23 11:53 ` [Bug c/49120] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-05-23 11:58 ` jakub at gcc dot gnu.org
2011-05-23 13:14 ` jakub at gcc dot gnu.org
2011-05-23 18:18 ` jakub at gcc dot gnu.org
2011-05-23 18:35 ` jakub at gcc dot gnu.org
2011-05-23 18:55 ` [Bug c/49120] [4.5 " jakub at gcc dot gnu.org
2011-07-19 12:51 ` jakub at gcc dot gnu.org
2011-07-19 13:42 ` jakub 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).