This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: typeof throws away the reference


"Giovanni Bajo" <giovannibajo@libero.it> writes:

| 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).

   http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1705.pdf
   http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1721.pdf

The last one reflects the outcome of the Redmond discussion and
temporarily splits the auto proposal from the decltype type proposal.


| 
| Giovanni Bajo

-- 
                                                       Gabriel Dos Reis 
                                           gdr@integrable-solutions.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]