public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8316: Confusing diagnostic for code that misuses conversion operators
@ 2003-03-18 20:36 jason
  0 siblings, 0 replies; 5+ messages in thread
From: jason @ 2003-03-18 20:36 UTC (permalink / raw)
  To: austern, gcc-bugs, gcc-prs, jason, nobody

Synopsis: Confusing diagnostic for code that misuses conversion operators

Responsible-Changed-From-To: unassigned->jason
Responsible-Changed-By: jason
Responsible-Changed-When: Tue Mar 18 20:36:39 2003
Responsible-Changed-Why:
    mine

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8316


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

* Re: c++/8316: Confusing diagnostic for code that misuses conversion operators
@ 2003-03-19 18:24 jason
  0 siblings, 0 replies; 5+ messages in thread
From: jason @ 2003-03-19 18:24 UTC (permalink / raw)
  To: austern, gcc-bugs, gcc-prs, jason

Synopsis: Confusing diagnostic for code that misuses conversion operators

State-Changed-From-To: analyzed->closed
State-Changed-By: jason
State-Changed-When: Wed Mar 19 18:24:31 2003
State-Changed-Why:
    message improved

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8316


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

* Re: c++/8316: Confusing diagnostic for code that misuses conversion operators
@ 2002-12-19 17:16 bangerth
  0 siblings, 0 replies; 5+ messages in thread
From: bangerth @ 2002-12-19 17:16 UTC (permalink / raw)
  To: austern, gcc-bugs, gcc-prs, nobody

Synopsis: Confusing diagnostic for code that misuses conversion operators

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Dec 19 17:16:34 2002
State-Changed-Why:
    Confirmed.
    
    Apart from the unnecessary duplication of error messages
    (where does this come from, this is not even a template
    which would be processed in two phases?), I can only
    think of telling that
      X::operator[] (char)
    is chosen over
      ::operator[] (whatever)
    (note the :: at the beginning). Matt, what better message
    do you have in mind? I think it is not so obvious
    what to say here.
    
    W.
    
    (Ah, and having an index operator that takes a character
    instead of an integer is an abuse as well :-)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8316


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

* c++/8316: Confusing diagnostic for code that misuses conversion operators
@ 2002-10-24  8:26 austern
  0 siblings, 0 replies; 5+ messages in thread
From: austern @ 2002-10-24  8:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8316; it has been noted by GNATS.

From: austern@apple.com
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8316: Confusing diagnostic for code that misuses conversion operators
Date: 23 Oct 2002 04:29:40 -0000

 >Number:         8316
 >Category:       c++
 >Synopsis:       Confusing diagnostic for code that misuses conversion operators
 >Confidential:   no
 >Severity:       serious
 >Priority:       medium
 >Responsible:    unassigned
 >State:          open
 >Class:          sw-bug
 >Submitter-Id:   net
 >Arrival-Date:   Tue Oct 22 21:36:00 PDT 2002
 >Closed-Date:
 >Last-Modified:
 >Originator:     austern@apple.com
 >Release:        3.1, 3.2, pre-3.3 TOT
 >Organization:
 >Environment:
 Linux
 >Description:
 Consider the following code fragment:
 struct X {
   char &operator[](char i);
   operator char *();
   operator const char *() const;
 };
 
 void f(X &x)
 {
   x[0] += 1;
 }
 
 Obviously this is bad practice, since x[0] should be interpreted too ways.  The compiler ought to tell the programmer that he/she is doing something wrong.
 
 The compiler does do that.  However, the diagnostic is so confusing that a user who would make this mistake is unlikely to be able to figure out what the compiler is saying.
 
 With 3.1 and 3.2, the output is:
 bash-2.05$ /usr/local/gcc-3.1/bin/g++ -c foo.cc
 foo.cc: In function `void f(X&)':
 foo.cc:11: choosing `char& X::operator[](char)' over `operator[]'
 foo.cc:11:   because worst conversion for the former is better than worst 
    conversion for the latter
 foo.cc:11: choosing `char& X::operator[](char)' over `operator[]'
 foo.cc:11:   because worst conversion for the former is better than worst 
    conversion for the latter
 
 Note that (1) the warning is repeated; and (2) it doesn't get to the heart of the matter and tell the user that it's a bad idea to provide both operator* and operator[].  A user is unlikely to be able to understand the problem from reading this message.
 
 With 3.3 the behavior is exactly the same, except that 'warning' is replaced by 'error'.  This is not an improvement.
 >How-To-Repeat:
 
 >Fix:
 
 >Release-Note:
 >Audit-Trail:
 >Unformatted:


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

* c++/8316: Confusing diagnostic for code that misuses conversion operators
@ 2002-10-22 21:36 austern
  0 siblings, 0 replies; 5+ messages in thread
From: austern @ 2002-10-22 21:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8316
>Category:       c++
>Synopsis:       Confusing diagnostic for code that misuses conversion operators
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 22 21:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     austern@apple.com
>Release:        3.1, 3.2, pre-3.3 TOT
>Organization:
>Environment:
Linux
>Description:
Consider the following code fragment:
struct X {
  char &operator[](char i);
  operator char *();
  operator const char *() const;
};

void f(X &x)
{
  x[0] += 1;
}

Obviously this is bad practice, since x[0] should be interpreted too ways.  The compiler ought to tell the programmer that he/she is doing something wrong.

The compiler does do that.  However, the diagnostic is so confusing that a user who would make this mistake is unlikely to be able to figure out what the compiler is saying.

With 3.1 and 3.2, the output is:
bash-2.05$ /usr/local/gcc-3.1/bin/g++ -c foo.cc
foo.cc: In function `void f(X&)':
foo.cc:11: choosing `char& X::operator[](char)' over `operator[]'
foo.cc:11:   because worst conversion for the former is better than worst 
   conversion for the latter
foo.cc:11: choosing `char& X::operator[](char)' over `operator[]'
foo.cc:11:   because worst conversion for the former is better than worst 
   conversion for the latter

Note that (1) the warning is repeated; and (2) it doesn't get to the heart of the matter and tell the user that it's a bad idea to provide both operator* and operator[].  A user is unlikely to be able to understand the problem from reading this message.

With 3.3 the behavior is exactly the same, except that 'warning' is replaced by 'error'.  This is not an improvement.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2003-03-19 18:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18 20:36 c++/8316: Confusing diagnostic for code that misuses conversion operators jason
  -- strict thread matches above, loose matches on Subject: below --
2003-03-19 18:24 jason
2002-12-19 17:16 bangerth
2002-10-24  8:26 austern
2002-10-22 21:36 austern

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