public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22256] New: diagnostic shows wrong type
@ 2005-06-30 16:30 igodard at pacbell dot net
  2005-06-30 17:14 ` [Bug c++/22256] " bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2005-06-30 16:30 UTC (permalink / raw)
  To: gcc-bugs

struct node { int*      operator int*(); };

gets you:

foo.cc:1: error: operator `int*' declared to return `int'

BTW, a better diagnostic would be something like:
error: operator `int*' should not declare a return type

-- 
           Summary: diagnostic shows wrong type
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
@ 2005-06-30 17:14 ` bangerth at dealii dot org
  2005-06-30 17:15 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-06-30 17:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-06-30 17:14 -------
Confirmed. Also happens with 3.3.x. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-30 17:14:37
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
  2005-06-30 17:14 ` [Bug c++/22256] " bangerth at dealii dot org
@ 2005-06-30 17:15 ` bangerth at dealii dot org
  2005-06-30 17:45 ` [Bug c++/22256] diagnostic shows wrong type for cast operator pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-06-30 17:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-06-30 17:15 -------
FWIW, here's the icc output: 
 
tmp/g> icc -Xc -ansi -c x.cc 
x.cc(1): error: return type may not be specified on a conversion function 
  struct node { int*      operator int*(); }; 
                          ^ 
 
 

-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type for cast operator
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
  2005-06-30 17:14 ` [Bug c++/22256] " bangerth at dealii dot org
  2005-06-30 17:15 ` bangerth at dealii dot org
@ 2005-06-30 17:45 ` pinskia at gcc dot gnu dot org
  2005-06-30 20:56 ` gdr at integrable-solutions dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30 17:45 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Keywords|                            |diagnostic
      Known to fail|                            |2.95 3.0.4 3.2.2 4.0.0 3.4.0
                   |                            |3.3.3
            Summary|diagnostic shows wrong type |diagnostic shows wrong type
                   |                            |for cast operator


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type for cast operator
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2005-06-30 17:45 ` [Bug c++/22256] diagnostic shows wrong type for cast operator pinskia at gcc dot gnu dot org
@ 2005-06-30 20:56 ` gdr at integrable-solutions dot net
  2005-06-30 21:48 ` igodard at pacbell dot net
  2005-06-30 22:11 ` gdr at integrable-solutions dot net
  5 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-06-30 20:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2005-06-30 20:56 -------
Subject: Re:  diagnostic shows wrong type

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Confirmed. Also happens with 3.3.x. 

I think this happens because when the C++ front-end finds that a
declaration is erroneous, it sets its TREE_TYPE to  "int", presumably
thinking that a default type should be "int".

-- Gaby


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type for cast operator
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2005-06-30 20:56 ` gdr at integrable-solutions dot net
@ 2005-06-30 21:48 ` igodard at pacbell dot net
  2005-06-30 22:11   ` Gabriel Dos Reis
  2005-06-30 22:11 ` gdr at integrable-solutions dot net
  5 siblings, 1 reply; 9+ messages in thread
From: igodard at pacbell dot net @ 2005-06-30 21:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2005-06-30 21:48 -------
Gabriel: no, it also happens with any pointer:

struct node { float*        operator float*(); };

gets you:

foo.cc:1: error: operator `float*' declared to return `float'

And similarly for other types including classes (not shown).

BTW, shouldn't the title be "diagnostic shows wrong type for conversion
function" ? I've never heard these called "cast operators".

-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type for cast operator
  2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2005-06-30 21:48 ` igodard at pacbell dot net
@ 2005-06-30 22:11 ` gdr at integrable-solutions dot net
  5 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-06-30 22:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2005-06-30 22:11 -------
Subject: Re:  diagnostic shows wrong type for cast operator

"igodard at pacbell dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| Gabriel: no, it also happens with any pointer:
| 
| struct node { float*        operator float*(); };
| 
| gets you:
| 
| foo.cc:1: error: operator `float*' declared to return `float'

Alright, that was a wrong guess.

-- Gaby


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Bug c++/22256] diagnostic shows wrong type for cast operator
  2005-06-30 21:48 ` igodard at pacbell dot net
@ 2005-06-30 22:11   ` Gabriel Dos Reis
  0 siblings, 0 replies; 9+ messages in thread
From: Gabriel Dos Reis @ 2005-06-30 22:11 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

"igodard at pacbell dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| Gabriel: no, it also happens with any pointer:
| 
| struct node { float*        operator float*(); };
| 
| gets you:
| 
| foo.cc:1: error: operator `float*' declared to return `float'

Alright, that was a wrong guess.

-- Gaby


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/22256] diagnostic shows wrong type for cast operator
       [not found] <bug-22256-6594@http.gcc.gnu.org/bugzilla/>
@ 2007-08-06 11:52 ` pcarlini at suse dot de
  0 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2007-08-06 11:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2007-08-06 11:52 -------
The subtle issue here is that this specific error message should be emitted
*only* when the incorrectly specified return type doesn't match, thus a plain
error instead of a pedwarn:

    case sfk_conversion:
      if (type && !same_type_p (type, optype))
        error ("operator %qT declared to return %qT", optype, type);
      else if (type)
        pedwarn ("return type specified for %<operator %T%>",  optype);
      type = optype;

but for some reason the thing doesn't work... I'm looking a bit into it.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-08-06 11:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-30 16:30 [Bug c++/22256] New: diagnostic shows wrong type igodard at pacbell dot net
2005-06-30 17:14 ` [Bug c++/22256] " bangerth at dealii dot org
2005-06-30 17:15 ` bangerth at dealii dot org
2005-06-30 17:45 ` [Bug c++/22256] diagnostic shows wrong type for cast operator pinskia at gcc dot gnu dot org
2005-06-30 20:56 ` gdr at integrable-solutions dot net
2005-06-30 21:48 ` igodard at pacbell dot net
2005-06-30 22:11   ` Gabriel Dos Reis
2005-06-30 22:11 ` gdr at integrable-solutions dot net
     [not found] <bug-22256-6594@http.gcc.gnu.org/bugzilla/>
2007-08-06 11:52 ` pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).