This is the mail archive of the gcc-bugs@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]

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


------- Additional Comments From gdr at integrable-solutions dot net  2003-11-12 14:29 -------
Subject: Re:  [3.4 Regression] gcc rejects typeof use for the return type

"gabor dot greif at lucent dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| ------- Additional Comments From gabor dot greif at lucent dot com  2003-11-12 14:03 -------
| (In reply to comment #6)
| > ...
| > 
| > | I ask myself why a typeof construct cannot be an unqualified-id?
| > 
| > Meaning?
| > 
| > -- Gaby
| > 
| 
| Hmmm, I assume you do not understand what I am meaning. (Your question is a bit
| overloaded :-)

Thnks for successfully resolving the call :-)

| Here is what I think. Let's modify my the simplified example:
| 
| 
| 
| struct bar
| {
|     void setfoobar(int);
|     int getfoobar(void) const;
|     static int (bar::* const getter1)(void) const;
| };
| 
| template <typename T>
| T* JustAPointer(void);
| 
| typedef __typeof__(JustAPointer<bar>()->getfoobar()) GETTER_RESULT;
| 
| GETTER_RESULT (bar::* const bar::getter1)(void)
| const = &bar::getfoobar;
| --------------------------------------------------------------------
| 
| I strongly assume this is legal _and_ compiles.

Given that this is a GNU extension, it is valid construct only if the
doc says so :-)  But I can see your point.
As an aside, the next version of C++ will have something like typeof
called "decltype", which is a "reference preserving typeof".  The
current draft stabdardese says that decltype(<some-expression>) is a
simple-type-specifier -- which is not the same as an unqualified-id. 

| GETTER_RESULT is a typedef-name, right?
| The new C++ parser only accepts an unqualified-id in that
| position, so typedef-name implies unqualified-id.
| 
| Now, by statement of Mark (comment #3), a typeof construct can be used
| everywhere a typedef-name can occur. So typeof-construct implies typedef-name
| (basically), and by transitiveness: typeof-construct implies unqualified-id.

I can't follow.  Mark was saying that in standardese, it would be a
simple-type-specifier (and I agree with him), and a
simple-type-specifier does not imply an unqualified name.

| Maybe I am a bit dense today, but I still cannot see what is illegal in the
| example in comment #1.

I can see an implementation problem but I can't see a problem from user
point-of-view.  And with compatibility with decltype, I would accept
the code, but I'm not going to fix it now so I can't revert Mark's
decision.  I can just suggest a feature-request.

-- Gaby


-- 


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


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