Re: Use an undefined variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux