[Bug c++/12581] [3.4 Regression] gcc rejects typeof use for the return type

gabor dot greif at lucent dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 13 08:23:00 GMT 2003


------- Additional Comments From gabor dot greif at lucent dot com  2003-11-13 08:22 -------
(In reply to comment #9)
> There are two pieces of code in this PR; comment #1 and comment #2.
> 

No. There is the PR description too. _That_ is the problem. As I mentioned
before,  comment #1 (as viewed in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12581) is bogus IMHO. I see no
connection between the Description and comment #1. I am not intending to follow
on for reasons of impertinence, but let's not get sidetracked by those comments
and focus on the PR which deals with a PTMF type that has a typeof in the result
position. All g++ versions (going back till egcs) supported that, but gcc3.4
breaks (I did not check 3.3).

Mark, in this case your analogy typeof<-->sizeof is hinking, because a sizeof
expression cannot stand in the result-type position of a PTMF type. Also, there
is not paren-less version ot typeof.
In the meantime I found a workaround that looks like this:
-----------------------------------
...
template <typename T> struct Id { typedef T is; };

Id<__typeof__(JustAPointer<bar>()->getfoobar())>::is (bar::* const
bar::getter1)(void)
const = &bar::getfoobar;
-----------------------------------

(The trick is to use typeof inside of the <>, where the parser seems to readily
accept it.)

I can hardly believe that parsing the latter is easier that what is in the
Description :-)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12581



More information about the Gcc-bugs mailing list