Returning a reference to local function parameters

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

 



Hi,

does anyone know why the following peace of code compiles without warning?:

int& max(int x, int y)
{
    return (x < y)? y: x;
}

I would expect a warning message like "warning: reference to local
variable... returned", but there isn't any warning.
I can only guess that it is a runtime decision which reference to which
variable should be returned. But why can't gcc take care of it and
doesn't print a warning message like the above one?

Thanks in advance,
Steve

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[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