Message ID | 4C2B2B9E.1010005@codesourcery.com |
---|---|
State | New |
Headers | show |
On 30 June 2010 13:33, Bernd Schmidt <bernds@codesourcery.com> wrote: > On 06/30/2010 12:00 PM, Manuel López-Ibáñez wrote: > >> /* { dg-message "note: 'b' was declared here" } */ > > When I tried something like this initially I couldn't get it to work, so > I started looking at other testcases. I've tried again now - how about > this version? I am not sure what the problem was, perhaps the quotes? If it works now (it should), this version is OK. Thanks, Manuel.
> + int b; /* { dg-message "note: 'b' was declared here" } */ > + if (b < 40) { > + ptr[0] = b; /* { dg-warning "may be used uninitialized" } */ > + } > + b += 1; I'd be interested to know why the warning appears on the second use of the uninitialized variable and not the first. r~
On Wed, Jun 30, 2010 at 6:32 PM, Richard Henderson <rth@redhat.com> wrote: >> + int b; /* { dg-message "note: 'b' was declared here" } */ >> + if (b < 40) { >> + ptr[0] = b; /* { dg-warning "may be used uninitialized" } */ >> + } >> + b += 1; > > I'd be interested to know why the warning appears on the > second use of the uninitialized variable and not the first. I bet the comparison is optimized away, only the store retained. Richard. > > r~ >
On Wed, Jun 30, 2010 at 4:33 AM, Bernd Schmidt <bernds@codesourcery.com> wrote: > On 06/30/2010 12:00 PM, Manuel López-Ibáñez wrote: > >> /* { dg-message "note: 'b' was declared here" } */ > > When I tried something like this initially I couldn't get it to work, so > I started looking at other testcases. I've tried again now - how about > this version? The test failed with -m32 on Linux/x86-64: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44738 But they work for 32bit gcc.
On 1 July 2010 02:57, H.J. Lu <hjl.tools@gmail.com> wrote: > On Wed, Jun 30, 2010 at 4:33 AM, Bernd Schmidt <bernds@codesourcery.com> wrote: >> On 06/30/2010 12:00 PM, Manuel López-Ibáñez wrote: >> >>> /* { dg-message "note: 'b' was declared here" } */ >> >> When I tried something like this initially I couldn't get it to work, so >> I started looking at other testcases. I've tried again now - how about >> this version? > > The test failed with -m32 on Linux/x86-64: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44738 > > But they work for 32bit gcc. It seems a location bug. Moving the dg-message around does hide the bug for this test but the bug is still there. Tests are supposed to catch bugs and this test is catching one. If you don't want to fix it, then don't, but don't hide it. Manuel.
On 06/30/2010 07:33 PM, Bernd Schmidt wrote: > On 06/30/2010 12:00 PM, Manuel López-Ibáñez wrote: > >> > /* { dg-message "note: 'b' was declared here" } */ > When I tried something like this initially I couldn't get it to work, so > I started looking at other testcases. I've tried again now - how about > this version? > > PR tree-optimization/39799 > * tree-inline.c (remap_ssa_name): Initialize variable only if > SSA_NAME_OCCURS_IN_ABNORMAL_PHI. > > PR tree-optimization/39799 > * c-c++-common/uninit-17.c: New test. > This might cause http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44921
Index: tree-inline.c =================================================================== --- tree-inline.c (revision 161540) +++ tree-inline.c (working copy) @@ -234,6 +234,7 @@ remap_ssa_name (tree name, copy_body_dat regions of the CFG, but this is expensive to test. */ if (id->entry_bb && is_gimple_reg (SSA_NAME_VAR (name)) + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name) && TREE_CODE (SSA_NAME_VAR (name)) != PARM_DECL && (id->entry_bb != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest || EDGE_COUNT (id->entry_bb->preds) != 1)) Index: testsuite/c-c++-common/uninit-17.c =================================================================== --- testsuite/c-c++-common/uninit-17.c (revision 0) +++ testsuite/c-c++-common/uninit-17.c (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +inline int foo(int x) +{ + return x; +} +static void bar(int a, int *ptr) +{ + do + { + int b; /* { dg-message "note: 'b' was declared here" } */ + if (b < 40) { + ptr[0] = b; /* { dg-warning "may be used uninitialized" } */ + } + b += 1; + ptr++; + } + while (--a != 0); +} +void foobar(int a, int *ptr) +{ + bar(foo(a), ptr); +} +
On 06/30/2010 12:00 PM, Manuel López-Ibáñez wrote: > /* { dg-message "note: 'b' was declared here" } */ When I tried something like this initially I couldn't get it to work, so I started looking at other testcases. I've tried again now - how about this version? Bernd PR tree-optimization/39799 * tree-inline.c (remap_ssa_name): Initialize variable only if SSA_NAME_OCCURS_IN_ABNORMAL_PHI. PR tree-optimization/39799 * c-c++-common/uninit-17.c: New test.