public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54583] New: Spurious warning: value computed is not used with variable-size array
@ 2012-09-14 20:17 stuff0002 at pobox dot com
  2012-10-30  1:07 ` [Bug c++/54583] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stuff0002 at pobox dot com @ 2012-09-14 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54583
           Summary: Spurious warning: value computed is not used with
                    variable-size array
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: stuff0002@pobox.com


When declaring a two-dimensional array with variable-length second dimension,
there is a warning "value computed is not used". For example:

$ cat warn1.cpp
void fred(){
  int n=10;
  double (*x)[n];
}
$ g++ -c warn1.cpp -Wall
warn1.cpp: In function ‘void fred()’:
warn1.cpp:3:16: warning: value computed is not used [-Wunused-value]
warn1.cpp:3:12: warning: unused variable ‘x’ [-Wunused-variable]

The second warning ("unused variable") is to be expected of course, and is not
the subject of this bug report. I don't believe the fact that x isn't used is
relevant to the first warning, so code that uses x is omitted in the above
example in the interests of constructing a minimal example. But to check, here
is a longer example that uses x:

$ cat warn2.cpp
#include <stdio.h>
#include <stdlib.h>

#define M 10
void fred(){
  int a,b,n;
  n=10;
  double (*x)[n];
  x=(double(*)[n])malloc(M*n*sizeof(double));
  for(a=0;a<M;a++)for(b=0;b<n;b++)x[a][b]=3;
  for(a=0;a<M;a++)for(b=0;b<n;b++)printf("%g\n",x[a][b]);
}
$ g++ -c warn2.cpp -Wall
warn2.cpp: In function ‘void fred()’:
warn2.cpp:8:16: warning: value computed is not used [-Wunused-value]


g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
...


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

* [Bug c++/54583] Spurious warning: value computed is not used with variable-size array
  2012-09-14 20:17 [Bug c++/54583] New: Spurious warning: value computed is not used with variable-size array stuff0002 at pobox dot com
@ 2012-10-30  1:07 ` paolo.carlini at oracle dot com
  2012-10-31 19:15 ` paolo at gcc dot gnu.org
  2012-10-31 19:17 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-30  1:07 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-10-30
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-30 01:07:27 UTC ---
Mine.


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

* [Bug c++/54583] Spurious warning: value computed is not used with variable-size array
  2012-09-14 20:17 [Bug c++/54583] New: Spurious warning: value computed is not used with variable-size array stuff0002 at pobox dot com
  2012-10-30  1:07 ` [Bug c++/54583] " paolo.carlini at oracle dot com
@ 2012-10-31 19:15 ` paolo at gcc dot gnu.org
  2012-10-31 19:17 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-10-31 19:15 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-10-31 19:14:44 UTC ---
Author: paolo
Date: Wed Oct 31 19:14:39 2012
New Revision: 193043

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193043
Log:
/cp
2012-10-31  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54583
    * tree.c (build_cplus_array_type): Set TREE_NO_WARNING on the
    TYPE_SIZE of VLAs.

/testsuite
2012-10-31  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54583
    * g++.dg/ext/vla13.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/ext/vla13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/54583] Spurious warning: value computed is not used with variable-size array
  2012-09-14 20:17 [Bug c++/54583] New: Spurious warning: value computed is not used with variable-size array stuff0002 at pobox dot com
  2012-10-30  1:07 ` [Bug c++/54583] " paolo.carlini at oracle dot com
  2012-10-31 19:15 ` paolo at gcc dot gnu.org
@ 2012-10-31 19:17 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-31 19:17 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-31 19:16:40 UTC ---
Fixed for 4.8.0.


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

end of thread, other threads:[~2012-10-31 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-14 20:17 [Bug c++/54583] New: Spurious warning: value computed is not used with variable-size array stuff0002 at pobox dot com
2012-10-30  1:07 ` [Bug c++/54583] " paolo.carlini at oracle dot com
2012-10-31 19:15 ` paolo at gcc dot gnu.org
2012-10-31 19:17 ` paolo.carlini at oracle dot com

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