Bug 65301 - gcc can't detect some uninit reads in ctor init lists
Summary: gcc can't detect some uninit reads in ctor init lists
Status: RESOLVED DUPLICATE of bug 19808
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2015-03-03 15:55 UTC by David Binderman
Modified: 2015-03-03 17:45 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2015-03-03 15:55:22 UTC
Given the following source code

class K
    K * copy();

class FunctionExpr
    FunctionExpr( const FunctionExpr & );

    K * args;

FunctionExpr::FunctionExpr(const FunctionExpr& expr)
        : args(expr.args ? args->copy() : 0)

then trunk gcc can't detect the read of uninit memory for args->copy.

$ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic bug189.cc

Here is clang doing the right thing:

$ ~/llvm/results/bin/clang++ -c -g -O2 -Wall -Wextra -pedantic bug189.cc
bug189.cc:18:28: warning: field 'args' is uninitialized when used here
        : args(expr.args ? args->copy() : 0)
1 warning generated.
Comment 1 Jonathan Wakely 2015-03-03 16:28:33 UTC
Yes, this is well known and a dup of another bug, maybe several.
Comment 2 Jonathan Wakely 2015-03-03 16:31:16 UTC
I pointed out other similar cases in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18016#c9 when fixing the simple case of args(args)
Comment 3 Manuel López-Ibáñez 2015-03-03 17:45:27 UTC
I think this is relatively easy to fix (seehttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=19808#c24). I think Anthony mentioned to me that he got it mostly working, but I haven't heard from him in a while.

*** This bug has been marked as a duplicate of bug 19808 ***