Re: How to let C++ compiler raise a warning or error when a const is assigned to a const reference?

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

 



"Peng Yu" <pengyu.ut@xxxxxxxxx> writes:
> I think the compiler should suspect there is something wrong, because
> the buggy code assigns the reference of a temp variable to a const
> reference. It should be that a const reference be assigned to another
> const reference.

It's not "assigning a temp to a const reference" (that's done all the
time, and is perfectly innocent), it's "assigning a reference to a
variable with a certain extent to a reference with a longer-lived
extent."  Does gcc have the information easily available to detect that?

-Miles
-- 
`...the Soviet Union was sliding in to an economic collapse so comprehensive
 that in the end its factories produced not goods but bads: finished products
 less valuable than the raw materials they were made from.'  [The Economist]


[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