"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]