This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: typeof throws away the reference
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: "Jari Petter Sundell" <jaris at student dot matnat dot uio dot no>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 28 Jan 2005 16:04:47 +0100
- Subject: Re: typeof throws away the reference
- References: <Pine.LNX.4.58-L.0501281531490.28742@northri.ifi.uio.no>
Jari Petter Sundell <jaris@student.matnat.uio.no> wrote:
> Compiling the following on g++-3.3 and 3.5-tree-ssa does not give a
> "could not convert `0' to ` int&'" for either of the assignments. Why
> doesn't typeof preserve the reference?
>
> int& f();
>
> int main() {
> int& a = f();
>
> typeof(a) r = 0;
> typeof(f()) s = 0;
> }
Because our implementation of typeof is the so-called "reference-dropping
typeof". There are pros and cons. This document should give you some clue:
http://www.osl.iu.edu/~jajarvi/publications/papers/decltype_revisited_n1527.pdf
(not sure if it's the last version).
Giovanni Bajo