[Bug c++/22238] Awful error messages with virtual functions

2018-02-19 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #25 from Jonathan Wakely  ---
(In reply to AK from comment #24)
> The recent error messages look much better. Maybe we can close this.
> 
> prog.cpp: In member function ‘void A::bar()’:
> prog.cpp:6:23: error: could not convert ‘A::foo()’ from ‘void’ to ‘bool’
>void bar() { if (foo()) ; }

There are other issues being tracked here, like the one in comment 12.

[Bug c++/22238] Awful error messages with virtual functions

2018-02-18 Thread hiraditya at msn dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

AK  changed:

   What|Removed |Added

 CC||hiraditya at msn dot com

--- Comment #24 from AK  ---
The recent error messages look much better. Maybe we can close this.

prog.cpp: In member function ‘void A::bar()’:
prog.cpp:6:23: error: could not convert ‘A::foo()’ from ‘void’ to ‘bool’
   void bar() { if (foo()) ; }

[Bug c++/22238] Awful error messages with virtual functions

2016-01-27 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #22 from David Malcolm  ---
(In reply to Manuel López-Ibáñez from comment #20)
[...]
> I maintain my opinion that any user-facing diagnostic using %qE is
> potentially broken.

Thanks; I'm inclined to agree.

Notes to self: implementation of %qE is in cp/error.c:cp_printer, which calls
expr_to_string.

$ grep "%qE" gcc/cp/*.c | wc -l
195

[Bug c++/22238] Awful error messages with virtual functions

2016-01-27 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #21 from Manuel López-Ibáñez  ---
(In reply to David Malcolm from comment #19)
> /tmp/test2.cc:9:24: error: return-statement with a value, in function
> returning 'void' [-fpermissive]
>  return P->bar() + *P;
> ^

And that location is terrible, but that is a different issue.

[Bug c++/22238] Awful error messages with virtual functions

2016-01-27 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

David Malcolm  changed:

   What|Removed |Added

 CC||dmalcolm at gcc dot gnu.org

--- Comment #19 from David Malcolm  ---
gcc trunk (r232888 fwiw) currently emits this for comment #0:

/tmp/test.cc: In member function ‘void A::bar()’:
/tmp/test.cc:4:23: error: could not convert ‘A::foo()’ from ‘void’ to ‘bool’
   void bar() { if (foo()) ; }
~~~^~

and this for the dup reported in PR 50817:

/tmp/test2.cc: In function ‘void test(foo*)’:
/tmp/test2.cc:9:21: error: no match for ‘operator+’ (operand types are ‘int’
and ‘foo’)
 return P->bar() + *P;
~^~~~
/tmp/test2.cc:9:24: error: return-statement with a value, in function returning
'void' [-fpermissive]
 return P->bar() + *P;
^

Is it time to close this one out as fixed?

[Bug c++/22238] Awful error messages with virtual functions

2016-01-27 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #20 from Manuel López-Ibáñez  ---
(In reply to David Malcolm from comment #19)
> Is it time to close this one out as fixed?

with gcc HEAD 6.0.0 20160127 and the testcase in comment #12, I get:

prog.cc: In member function 'void B::bar()':
prog.cc:8:25: error: could not convert '(((A*)this) + ((sizetype)(*(long
int*)(((B*)this)->B::_vptr.B + 18446744073709551592u->A::foo()' from 'void'
to 'bool'
 void bar() { if (foo()) ; }
  ~~~^~

Clang:

prog.cc:8:22: error: value of type 'void' is not contextually convertible to
'bool'
void bar() { if (foo()) ; }
 ^

I maintain my opinion that any user-facing diagnostic using %qE is potentially
broken.

[Bug c++/22238] Awful error messages with virtual functions

2016-01-27 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #23 from David Malcolm  ---
Created attachment 37496
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37496=edit
Patch to fix the case in comment #12 (for next stage 1)

[Bug c++/22238] Awful error messages with virtual functions

2011-12-01 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
 CC||jason at gcc dot gnu.org,
   ||manu at gcc dot gnu.org
 AssignedTo|gdr at gcc dot gnu.org  |unassigned at gcc dot
   ||gnu.org

--- Comment #16 from Manuel López-Ibáñez manu at gcc dot gnu.org 2011-12-01 
17:27:01 UTC ---
I think this is a duplicate of another PR I cannot find, but everything boils
down to please kill %qE and stop pretty-printing expressions. Behold the
beauty of clang:

pr22238.cc:8:20: error: value of type 'void' is not contextually convertible to
'bool'
  void bar() { if (foo()) ; }
   ^
1 error generated. 

(it looks even prettier with the default colors!)


[Bug c++/22238] Awful error messages with virtual functions

2011-12-01 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #17 from Jonathan Wakely redi at gcc dot gnu.org 2011-12-01 
17:39:24 UTC ---
(In reply to comment #16)
 I think this is a duplicate of another PR I cannot find

PR 50817 ?


[Bug c++/22238] Awful error messages with virtual functions

2011-12-01 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22238

--- Comment #18 from Manuel López-Ibáñez manu at gcc dot gnu.org 2011-12-01 
17:50:25 UTC ---
*** Bug 50817 has been marked as a duplicate of this bug. ***


[Bug c++/22238] Awful error messages with virtual functions

2007-08-21 Thread reichelt at gcc dot gnu dot org


--- Comment #14 from reichelt at gcc dot gnu dot org  2007-08-21 19:56 
---
The pointer_plus_exprt stuff has been fixed.

We are now back to error messages like

bug.cc: In member function 'void B::bar()':
bug.cc:4: error: could not convert '(((A*)this) + ((unsigned int)(*(int*)(
((B*)this)-B::_vptr.B + 0xfff4u-A::foo()' to 'bool'


-- 


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



[Bug c++/22238] Awful error messages with virtual functions

2007-08-21 Thread gdr at cs dot tamu dot edu


--- Comment #15 from gdr at cs dot tamu dot edu  2007-08-21 20:27 ---
Subject: Re:  Awful error messages with virtual functions

reichelt at gcc dot gnu dot org [EMAIL PROTECTED] writes:

| The pointer_plus_exprt stuff has been fixed.
| 
| We are now back to error messages like
| 
| bug.cc: In member function 'void B::bar()':
| bug.cc:4: error: could not convert '(((A*)this) + ((unsigned int)(*(int*)(
| ((B*)this)-B::_vptr.B + 0xfff4u-A::foo()' to 'bool'

Until we have a separate higher level representation in the C++
front-end, this is going to be hard to fix correctly.  The alternative
is that we don't print expressions at all -- but that cure seems to me
to be worse than the disease.

-- Gaby


-- 


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



[Bug c++/22238] Awful error messages with virtual functions

2007-06-17 Thread reichelt at gcc dot gnu dot org


--- Comment #12 from reichelt at gcc dot gnu dot org  2007-06-17 23:40 
---
Andrew, Gaby's testcase from comment #4 gets an even worse diagnostic
since the merge of the ptr_plus stuff:

=
struct A
{
void foo();
};

struct B : virtual A
{
void bar() { if (foo()) ; }
};
=

bug.cc: In member function 'void B::bar()':
bug.cc:8: error: could not convert '#'pointer_plus_expr' not supported by
dump_expr#expression error-A::foo()' to 'bool'

Would you mind having a look?


-- 

reichelt at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||pinskia at gcc dot gnu dot
   ||org


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



[Bug c++/22238] Awful error messages with virtual functions

2007-06-17 Thread pinskia at gcc dot gnu dot org


--- Comment #13 from pinskia at gcc dot gnu dot org  2007-06-17 23:42 
---
Would you mind having a look?

I was going to fix the pretty printing of pointer_plus_expr for C++ after I
returned from Japan.  I already have a testcase which is better than the one
here.


-- 


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