public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16696] New: Strange message when operator++ not found
@ 2004-07-23 20:39 bangerth at dealii dot org
  2004-07-23 20:58 ` [Bug c++/16696] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-07-23 20:39 UTC (permalink / raw)
  To: gcc-bugs

Take this: 
---------------- 
struct X { void operator++(); }; 
 
int main () { 
  X x; 
  x++; 
} 
--------------- 
Since there is indeed no postfix operator++ declared, the code is invalid, 
but we get a strange error message: 
 
g/x> /home/bangerth/tmp/gcc/b35/gcc/cc1plus -quiet -O2 xx.cc  
xx.cc: In function `int main()': 
xx.cc:5: error: no `operator++(int)' declared for postfix `++', trying prefix 
operator instead 
 
What does the compiler mean when it says "Trying prefix operator instead"? 
Does this imply that if there is one then it would use it? Hopefully not. 
However, if I remove the prefix form as well, i.e. do this: 
-------------------- 
struct X {}; 
 
int main () { 
  X x; 
  x++; 
} 
-------------------- 
then I get this instead: 
 
g/x> /home/bangerth/tmp/gcc/b35/gcc/cc1plus -quiet -O2 xx.cc  
xx.cc: In function `int main()': 
xx.cc:5: error: no `operator++(int)' declared for postfix `++', trying prefix 
operator instead 
xx.cc:5: error: no match for 'operator++' in '++x' 
 
Now, I think that's completely bogus: we do have a syntax error here, 
so why is the compiler pretending it is trying to find a way around it 
for me? If it said, as a note: 
  Note: the class declares a prefix operator++ instead 
then that would be fine, but the message that it is trying something else 
instead is too much AI for me... 
 
This behavior has been with us since at least 2.95. 
 
W.

-- 
           Summary: Strange message when operator++ not found
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
@ 2004-07-23 20:58 ` pinskia at gcc dot gnu dot org
  2004-07-23 21:02 ` bangerth at ices dot utexas dot edu
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-23 20:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-23 20:58 -------
I think there is a couple of missing words, "to use".
So it should read "xx.cc:5: error: no `operator++(int)' declared for postfix `++', trying to use prefix 
operator instead".

But you are right, this is bogus, maybe the problem is that we used (or still do with -fpremisive) try to 
use prefix version of the operators.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-23 20:58:37
               date|                            |


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
  2004-07-23 20:58 ` [Bug c++/16696] " pinskia at gcc dot gnu dot org
@ 2004-07-23 21:02 ` bangerth at ices dot utexas dot edu
  2004-07-23 21:08 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at ices dot utexas dot edu @ 2004-07-23 21:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at ices dot utexas dot edu  2004-07-23 21:02 -------
Subject: Re:  Strange message when operator++ not found


> But you are right, this is bogus, maybe the problem is that we used (or
> still do with -fpremisive) try to use prefix version of the operators.

Well, I sure hope we don't!

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/



-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
  2004-07-23 20:58 ` [Bug c++/16696] " pinskia at gcc dot gnu dot org
  2004-07-23 21:02 ` bangerth at ices dot utexas dot edu
@ 2004-07-23 21:08 ` pinskia at gcc dot gnu dot org
  2004-07-23 21:12 ` bangerth at ices dot utexas dot edu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-23 21:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-23 21:08 -------
It is special cased:
        case POSTINCREMENT_EXPR:
        case POSTDECREMENT_EXPR:
          /* Look for an `operator++ (int)'.  If they didn't have
             one, then we fall back to the old way of doing things.  */
          if (flags & LOOKUP_COMPLAIN)
            pedwarn ("no `%D(int)' declared for postfix `%s', trying prefix operator instead",
                        fnname, 
                        operator_name_info[code].name);
          if (code == POSTINCREMENT_EXPR)
            code = PREINCREMENT_EXPR;
          else
            code = PREDECREMENT_EXPR;
          result = build_new_op (code, flags, arg1, NULL_TREE, NULL_TREE,
                                 overloaded_p);

which means -fpermissive does look do the transformation. :(
Why we do this is unknown as it comes from PRE EGCSE (aka CVS days).

-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (2 preceding siblings ...)
  2004-07-23 21:08 ` pinskia at gcc dot gnu dot org
@ 2004-07-23 21:12 ` bangerth at ices dot utexas dot edu
  2004-07-23 21:14 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at ices dot utexas dot edu @ 2004-07-23 21:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at ices dot utexas dot edu  2004-07-23 21:12 -------
Subject: Re:  Strange message when operator++ not found


> which means -fpermissive does look do the transformation.

But I didn't specify -fpermissive. Why is it trying anyway? The code you show 
doesn't even seem to check for this flag, does it?

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/



-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (3 preceding siblings ...)
  2004-07-23 21:12 ` bangerth at ices dot utexas dot edu
@ 2004-07-23 21:14 ` pinskia at gcc dot gnu dot org
  2004-07-23 21:19 ` bangerth at ices dot utexas dot edu
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-23 21:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-23 21:14 -------
No it does not but pedwarn does so it turns it into an error which is why there is an error and not a 
warning.

-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (4 preceding siblings ...)
  2004-07-23 21:14 ` pinskia at gcc dot gnu dot org
@ 2004-07-23 21:19 ` bangerth at ices dot utexas dot edu
  2004-07-23 21:41 ` schwab at suse dot de
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at ices dot utexas dot edu @ 2004-07-23 21:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at ices dot utexas dot edu  2004-07-23 21:19 -------
Subject: Re:  Strange message when operator++ not found


But the code after it that turns a postfix into a prefix operator isn't 
guarded on that...

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/



-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (5 preceding siblings ...)
  2004-07-23 21:19 ` bangerth at ices dot utexas dot edu
@ 2004-07-23 21:41 ` schwab at suse dot de
  2004-07-23 23:27 ` bangerth at ices dot utexas dot edu
  2004-08-11 22:16 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: schwab at suse dot de @ 2004-07-23 21:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-07-23 21:41 -------
Pre-1985 C++ didn't distinguish between prefix and postfix ++ and operator++() 
was used for both. 

-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (6 preceding siblings ...)
  2004-07-23 21:41 ` schwab at suse dot de
@ 2004-07-23 23:27 ` bangerth at ices dot utexas dot edu
  2004-08-11 22:16 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at ices dot utexas dot edu @ 2004-07-23 23:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at ices dot utexas dot edu  2004-07-23 23:27 -------
Subject: Re:  Strange message when operator++ not found


> Pre-1985 C++

:-)) I thought I was old already, but apparently not old enough...
W.



-- 


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


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

* [Bug c++/16696] Strange message when operator++ not found
  2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
                   ` (7 preceding siblings ...)
  2004-07-23 23:27 ` bangerth at ices dot utexas dot edu
@ 2004-08-11 22:16 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-11 22:16 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |16992
              nThis|                            |


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


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

end of thread, other threads:[~2004-08-11 22:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-23 20:39 [Bug c++/16696] New: Strange message when operator++ not found bangerth at dealii dot org
2004-07-23 20:58 ` [Bug c++/16696] " pinskia at gcc dot gnu dot org
2004-07-23 21:02 ` bangerth at ices dot utexas dot edu
2004-07-23 21:08 ` pinskia at gcc dot gnu dot org
2004-07-23 21:12 ` bangerth at ices dot utexas dot edu
2004-07-23 21:14 ` pinskia at gcc dot gnu dot org
2004-07-23 21:19 ` bangerth at ices dot utexas dot edu
2004-07-23 21:41 ` schwab at suse dot de
2004-07-23 23:27 ` bangerth at ices dot utexas dot edu
2004-08-11 22:16 ` pinskia at gcc dot gnu dot org

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