Re: no warning when assigning a string to itself; infinite loop when printing a string

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

 



On 22 May 2011 19:10, Steve Ward wrote:
> In the attached code, the line "const string str = str;" doesn't give

That's not an assignment, it's construction.

> a warning.  Is this right?  If I change the data type to an "int", a
> warning is given. ("warning: 'str' is used uninitialized in this
> function")

It's a bug that there's no warning.  It fails to warn for any class types:

struct S { };

int main()
{
  const S s = s;
}

I think there's an open bug in bugzilla about this, but I can't find
it right now.

> Also, when trying to print the string, it seems to execute forever.

The program's behaviour is undefined, so it could do anything.



[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