Use an undefined variable
Andrew Haley
aph@redhat.com
Fri Mar 7 12:11:00 GMT 2008
Dario Saccavino wrote:
>> There is an unbounded number of incorrect C++ programs. We warn about
>> a subset of them. Detecting every incorrect C++ program is, I'm sure
>> an uncomputable problem.
>>
>
> The -Wuninitialized and -Winit-self options are meant to check exactly
> this kind of incorrect programs, and I'm quite disappointed that the
> following function
>
> template<class T> T f(T x)
> {
> T y = x + y;
> return y;
> }
>
> generates a warning when instantiated with T = int, but not when T =
> std::string.
Interesting.
> Furthermore, my impression is that the use of an uninitialized integer
> is "less incorrect" than the use of a complex object before even
> calling its constructor.
I have no idea where you got the idea that one is "less incorrect" than the
other. I'm pretty sure it wasn't from the C++ standard.
Andrew.
More information about the Gcc-help
mailing list