public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/22197] New: invalid "is" used uninitialized, should be "may be"
@ 2005-06-27 13:25 matz at suse dot de
2005-06-27 13:31 ` [Bug middle-end/22197] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: matz at suse dot de @ 2005-06-27 13:25 UTC (permalink / raw)
To: gcc-bugs
Compile this code with -O2 -Wall on 4.0.x or mainline:
-------------------------------------
struct testme {
int testval;
int unusedval;
};
extern void forget (struct testme forgotten);
int main () {
struct testme testarray[1];
struct testme testvar;
testvar.testval = 0;
testarray[0] = testvar;
forget (testarray[0]);
return 0;
}
--------------------------------------
This will give this warning:
unused.c:13: warning: ‘testvar.unusedval’ is used uninitialized in this
function
The problem is the copy of some uninitialized part. Yes, it does copy
something uninitialized, but that's okay, as long as it is not really
accessed. At the very least it should only be a "may be used uninit"
warning. This is only noticed by tree-sra. With -fno-tree-sra there's
no warning. So, in effect, accesses to uninitialized parts for purpose
of copying should not lead to such warning.
--
Summary: invalid "is" used uninitialized, should be "may be"
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at suse dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/22197] invalid "is" used uninitialized, should be "may be"
2005-06-27 13:25 [Bug middle-end/22197] New: invalid "is" used uninitialized, should be "may be" matz at suse dot de
@ 2005-06-27 13:31 ` pinskia at gcc dot gnu dot org
2005-06-27 13:50 ` matz at suse dot de
2005-06-27 13:57 ` schwab at suse dot de
2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-27 13:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-27 13:31 -------
but isn't that the same as (except it is an aggregate in the case in comment #1):
void g(int);
void f(void)
{
int i;
g(i);
}
because g might not look at the agrument value?
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/22197] invalid "is" used uninitialized, should be "may be"
2005-06-27 13:25 [Bug middle-end/22197] New: invalid "is" used uninitialized, should be "may be" matz at suse dot de
2005-06-27 13:31 ` [Bug middle-end/22197] " pinskia at gcc dot gnu dot org
@ 2005-06-27 13:50 ` matz at suse dot de
2005-06-27 13:57 ` schwab at suse dot de
2 siblings, 0 replies; 5+ messages in thread
From: matz at suse dot de @ 2005-06-27 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From matz at suse dot de 2005-06-27 13:50 -------
Hmm, sort of. The call of g(i) also warns with "is used", although I
think it might deserve only a "may be used". But anyway I think that
this nevertheless has different causes. It's not the call creating
the problem, but the copy itself. On could for instance delete the
call and instead make 'testarray' volatile (so that the copy is not
optimized away). This would still warn, IMHO incorrectly.
What's even stranger is, that if I add a call "forget(testvar)" then
the warning vanishes. I.e. like so:
-------------------------------------
int main() {
struct testme volatile testarray[1];
struct testme testvar;
testvar.testval = 0;
testarray[0] = testvar;
forget (testvar);
return 0;
}
-------------------------------------
So this shows that not the call on a partly initialized struct is the
problem (because that is still the case with the above), but something
in SRA dealing with the copy. If one removes the call to forget above
the warning will return (note the added volatile) on the copy.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/22197] invalid "is" used uninitialized, should be "may be"
2005-06-27 13:25 [Bug middle-end/22197] New: invalid "is" used uninitialized, should be "may be" matz at suse dot de
2005-06-27 13:31 ` [Bug middle-end/22197] " pinskia at gcc dot gnu dot org
2005-06-27 13:50 ` matz at suse dot de
@ 2005-06-27 13:57 ` schwab at suse dot de
2 siblings, 0 replies; 5+ messages in thread
From: schwab at suse dot de @ 2005-06-27 13:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From schwab at suse dot de 2005-06-27 13:57 -------
In the case of g(i) you have an initialisation of the parameter variable which
already constitutes a use of the value.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/22197] invalid "is" used uninitialized, should be "may be"
[not found] <bug-22197-183@http.gcc.gnu.org/bugzilla/>
@ 2005-11-26 7:44 ` gdr at gcc dot gnu dot org
0 siblings, 0 replies; 5+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-26 7:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gdr at gcc dot gnu dot org 2005-11-26 07:44 -------
(In reply to comment #2)
> Hmm, sort of. The call of g(i) also warns with "is used", although I
> think it might deserve only a "may be used". But anyway I think that
> this nevertheless has different causes. It's not the call creating
> the problem, but the copy itself.
yes, how a is copy not a use? At the very list, on modern architectures,
it implies memory->register->memory traffic of garbage data.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-26 7:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-27 13:25 [Bug middle-end/22197] New: invalid "is" used uninitialized, should be "may be" matz at suse dot de
2005-06-27 13:31 ` [Bug middle-end/22197] " pinskia at gcc dot gnu dot org
2005-06-27 13:50 ` matz at suse dot de
2005-06-27 13:57 ` schwab at suse dot de
[not found] <bug-22197-183@http.gcc.gnu.org/bugzilla/>
2005-11-26 7:44 ` gdr 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).