public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
@ 2010-05-13 11:03 rubidium at openttd dot org
2010-05-13 11:04 ` [Bug c++/44108] " rubidium at openttd dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: rubidium at openttd dot org @ 2010-05-13 11:03 UTC (permalink / raw)
To: gcc-bugs
Like PR c/43981, but still happening with 4.6.0 20100513 (Last Changed Rev:
159356
), which is why I copied and editted the title.
In case a const variable is used for array sizing it is not considered to be
read whereas a non-const variable would be considered to be read. It does NOT
happen when using gcc on a .c file, but it happens when using g++ on a .cpp
file, as such component c++.
See the attached test case which shows that only the const variables are
affected by this.
--
Summary: [4.6 Regression] -Wunused-but-set-variable does not
consider array sizing use of a const variable
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rubidium at openttd dot org
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
@ 2010-05-13 11:04 ` rubidium at openttd dot org
2010-05-13 12:18 ` rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rubidium at openttd dot org @ 2010-05-13 11:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rubidium at openttd dot org 2010-05-13 11:04 -------
Created an attachment (id=20655)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20655&action=view)
Simple testcase
Compile with g++ -Wunused-but-set-variable testcase.cpp
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
2010-05-13 11:04 ` [Bug c++/44108] " rubidium at openttd dot org
@ 2010-05-13 12:18 ` rguenth at gcc dot gnu dot org
2010-05-14 6:42 ` dodji at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-13 12:18 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
2010-05-13 11:04 ` [Bug c++/44108] " rubidium at openttd dot org
2010-05-13 12:18 ` rguenth at gcc dot gnu dot org
@ 2010-05-14 6:42 ` dodji at gcc dot gnu dot org
2010-05-14 7:25 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-05-14 6:42 UTC (permalink / raw)
To: gcc-bugs
--
dodji at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dodji at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-05-14 06:42:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
` (2 preceding siblings ...)
2010-05-14 6:42 ` dodji at gcc dot gnu dot org
@ 2010-05-14 7:25 ` jakub at gcc dot gnu dot org
2010-05-17 12:30 ` dodji at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-14 7:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jakub at gcc dot gnu dot org 2010-05-14 07:25 -------
Perhaps we just shouldn't ever warn for TREE_CONSTANT decls with
-Wunused-but-set-* ?
Such variables can't be ever set (the set is just the definition),
therefore all sets of TREE_USED for them are reads.
That said, it would be good to find out why we don't warn in that
case; for [M_CONST + 6] we do warn.
Or for DECL_INTEGRAL_CONSTANT_VAR_P decls, or for decls for which
integral_constant_value (decl) != decl not sure what is best.
In any case, compute_array_index_type (and probably many other spots)
calls integral_constant_value and thus
doesn't see the passed in decl anymore afterwards.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
` (3 preceding siblings ...)
2010-05-14 7:25 ` jakub at gcc dot gnu dot org
@ 2010-05-17 12:30 ` dodji at gcc dot gnu dot org
2010-05-17 13:54 ` dodji at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-05-17 12:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dodji at gcc dot gnu dot org 2010-05-17 12:30 -------
Created an attachment (id=20678)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20678&action=view)
Candidate patch
On Fri, May 14, 2010 at 07:25:18AM -0000, jakub at gcc dot gnu dot org wrote:
> That said, it would be good to find out why we don't warn in that
> case; for [M_CONST + 6] we do warn.
I think we don't warn in that case because M_CONST in the expression
M_CONST + 6, M_CONST is an rvalue use and we recognize it as such via
default_conversion that should be called on the arguments of the + expression.
We fail to recognize the use of [M_CONST], because M_CONST gets folded
into it's value without us marking that folding as an rvalue use. I
am thus testing the attached patch. The reason why the patch seems
convoluted is that I don't want to mark a dependant value as a rvalue
use. I believe only full instantiations should be marked.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
` (4 preceding siblings ...)
2010-05-17 12:30 ` dodji at gcc dot gnu dot org
@ 2010-05-17 13:54 ` dodji at gcc dot gnu dot org
2010-05-17 17:25 ` jakub at gcc dot gnu dot org
2010-05-17 19:45 ` dodji at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-05-17 13:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from dodji at gcc dot gnu dot org 2010-05-17 13:54 -------
Created an attachment (id=20681)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20681&action=view)
Don't warn for integral constants
Jakub, this one line patch implements the first idea which is to not warn for
integral constants, as far as Wunused_but_set_variable is concerned.
I have tested it only for the reported error case. I haven't regtested it yet.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
` (5 preceding siblings ...)
2010-05-17 13:54 ` dodji at gcc dot gnu dot org
@ 2010-05-17 17:25 ` jakub at gcc dot gnu dot org
2010-05-17 19:45 ` dodji at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-17 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2010-05-17 17:25 -------
Subject: Bug 44108
Author: jakub
Date: Mon May 17 17:24:32 2010
New Revision: 159497
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159497
Log:
PR c++/44108
* decl.c (compute_array_index_type): Call mark_rvalue_use.
* c-c++-common/Wunused-var-8.c: New test.
Added:
trunk/gcc/testsuite/c-c++-common/Wunused-var-8.c
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
` (6 preceding siblings ...)
2010-05-17 17:25 ` jakub at gcc dot gnu dot org
@ 2010-05-17 19:45 ` dodji at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-05-17 19:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from dodji at gcc dot gnu dot org 2010-05-17 19:45 -------
This should be fixed in trunk (4.6)
--
dodji at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-05-17 19:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-13 11:03 [Bug c++/44108] New: [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable rubidium at openttd dot org
2010-05-13 11:04 ` [Bug c++/44108] " rubidium at openttd dot org
2010-05-13 12:18 ` rguenth at gcc dot gnu dot org
2010-05-14 6:42 ` dodji at gcc dot gnu dot org
2010-05-14 7:25 ` jakub at gcc dot gnu dot org
2010-05-17 12:30 ` dodji at gcc dot gnu dot org
2010-05-17 13:54 ` dodji at gcc dot gnu dot org
2010-05-17 17:25 ` jakub at gcc dot gnu dot org
2010-05-17 19:45 ` dodji 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).