public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11866] New: poor diagnostic on undeclared exception
@ 2003-08-09 12:11 Rob_Davies at NTLworld dot com
  2003-08-09 12:48 ` [Bug c++/11866] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Rob_Davies at NTLworld dot com @ 2003-08-09 12:11 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: poor diagnostic on undeclared exception
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Rob_Davies at NTLworld dot com
                CC: gcc-bugs at gcc dot gnu dot org

This appears to be a default diagnostic and not very helpful.  I stumbled into 
it trying examples out of Stroustrup's C++ 3rd edition book (p 54) which fails 
to show inclusion of <stdexcept>, and I thought the class vector must define it 
in it's include file, so was flummoxed. 
 
rob@elm:/dl/rob/usp/cpp> g++ -DBREAK undeclared_exception.cpp 
undeclared_exception.cpp: In function `int main()': 
undeclared_exception.cpp:10: error: parse error before `)' token 
rob@elm:/dl/rob/usp/cpp> 
 
Reproduce with this code : 
 
#ifndef BREAK 
#include <stdexcept> 
#endif /* BREAK */ 
 
int main () { 
 
    try { 
        // something 
    } 
    catch (std::out_of_range) { 
    } 
    catch (...) { 
    } 
 
    return 0; 
} 
 
Anyway the point is, it would help the user lots to understand the problem, if 
a more informative message was given, as is usually the case eg) : 
 
3.cpp:27: error: 'map' is used as a type, but is not defined as a type. 
3.cpp: In function `void print_entry(std::basic_string<char, 
   std::char_traits<char>, std::allocator<char> >)': 
3.cpp:30: error: `phone_book' undeclared (first use this function) 
3.cpp:30: error: (Each undeclared identifier is reported only once for each 
   function it appears in.) 
 
Ideally something like : 
 
'std::out_of_range' is used as an exception, but is not defined as an exception 
. 
In function .... 
XX: error: 'std::out_of_range' undeclared (first use this function) 
... 
 
Thanks for the software, hope you can see how this would be an improvement. 
 
Rob


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
@ 2003-08-09 12:48 ` pinskia at gcc dot gnu dot org
  2003-08-11 14:58 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-09 12:48 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-09 12:48 -------
The mainline produces:
pr11866.cc: In function `int main()':
pr11866.cc:10: error: expected type-name
pr11866.cc:10: error: expected type-name
pr11866.cc:10: error: invalid catch parameter
pr11866.cc:10: error: `...' handler must be the last handler for its try block
which might be okay (but what is a type-name?, I know what it is but it is overused in the 
mainline's error messages.)


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
  2003-08-09 12:48 ` [Bug c++/11866] " pinskia at gcc dot gnu dot org
@ 2003-08-11 14:58 ` bangerth at dealii dot org
  2003-08-11 19:15 ` Rob_Davies at NTLworld dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-08-11 14:58 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


------- Additional Comments From bangerth at dealii dot org  2003-08-11 14:58 -------
I think in this case the new error message happens to be exactly right: the compiler 
sees a string it doesn't know, at a place where the name of a type is expected. At 
least one place where this diagnostic seems appropriate, so let's close this PR. 
 
W.


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
  2003-08-09 12:48 ` [Bug c++/11866] " pinskia at gcc dot gnu dot org
  2003-08-11 14:58 ` bangerth at dealii dot org
@ 2003-08-11 19:15 ` Rob_Davies at NTLworld dot com
  2003-08-11 21:05 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Rob_Davies at NTLworld dot com @ 2003-08-11 19:15 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From Rob_Davies at NTLworld dot com  2003-08-11 19:15 -------
The 3.4 message is an improvement, it is NOT exactly right however.  The 
reference to '...' being last is distracting.  Also catch parameter, and the 
type name stuff is not in the terms, the source developer thinks in. 
 
More to the point would be saying directly, "Undeclared exception  
'std:out_of_range' in catch handler". 
 
Having looked at the grammar in Stroustroup, it must be possible, as the 
try/catch is defined so : 
 
try-block: 
    try compound-statement handler-seq 
 
handler-seq: 
    handler handler-seqopt 
 
handler: 
    catch ( exception-declaration ) compound-statement 
 
 
The point is, the parser knows it's looking for an exception declaration at 
that point, so a really clear error message ought to be feasible. 
 
Clear error messages aid developer's alot, a specific message would have made 
my original problem a no brainer, simply grep to find the include file that 
declared the exception.


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
                   ` (2 preceding siblings ...)
  2003-08-11 19:15 ` Rob_Davies at NTLworld dot com
@ 2003-08-11 21:05 ` bangerth at dealii dot org
  2003-08-11 21:06 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-08-11 21:05 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdr at gcc dot gnu dot org
           Priority|P2                          |P3
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-11 21:05:00
               date|                            |
   Target Milestone|3.4                         |---


------- Additional Comments From bangerth at dealii dot org  2003-08-11 21:05 -------
Well, so let's keep it open then, but at low priority.
W.


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
                   ` (3 preceding siblings ...)
  2003-08-11 21:05 ` bangerth at dealii dot org
@ 2003-08-11 21:06 ` pinskia at gcc dot gnu dot org
  2003-08-11 21:28 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-11 21:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|FIXED                       |


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-11 21:06 -------
Wolfgang forgot to reopen it.


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
                   ` (4 preceding siblings ...)
  2003-08-11 21:06 ` pinskia at gcc dot gnu dot org
@ 2003-08-11 21:28 ` pinskia at gcc dot gnu dot org
  2003-08-11 22:32 ` Rob_Davies at NTLworld dot com
  2003-12-28 23:08 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-11 21:28 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|2003-08-11 21:05:00         |2003-08-11 21:28:11
               date|                            |


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-11 21:28 -------
Already confirmed by me and Wolfgang.


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
                   ` (5 preceding siblings ...)
  2003-08-11 21:28 ` pinskia at gcc dot gnu dot org
@ 2003-08-11 22:32 ` Rob_Davies at NTLworld dot com
  2003-12-28 23:08 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: Rob_Davies at NTLworld dot com @ 2003-08-11 22:32 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From Rob_Davies at NTLworld dot com  2003-08-11 22:32 -------
Subject: Re:  poor diagnostic on undeclared exception

On Monday 11 Aug 2003 22:28, pinskia at gcc dot gnu dot org wrote:

> ------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-11
> 21:28 ------- Already confirmed by me and Wolfgang.

Thanks, I'm happy with that it is an enhancement rather than a bug :)

Regard Rob


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

* [Bug c++/11866] poor diagnostic on undeclared exception
  2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
                   ` (6 preceding siblings ...)
  2003-08-11 22:32 ` Rob_Davies at NTLworld dot com
@ 2003-12-28 23:08 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-28 23:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-28 22:50 -------
Fixed for 3.4:
pr11866.cc: In function `int main()':
pr11866.cc:10: error: `std::out_of_range' has not been declared
pr11866.cc:10: error: invalid catch parameter
pr11866.cc:10: error: `...' handler must be the last handler for its try block

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.4.0


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


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

end of thread, other threads:[~2003-12-28 22:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-09 12:11 [Bug c++/11866] New: poor diagnostic on undeclared exception Rob_Davies at NTLworld dot com
2003-08-09 12:48 ` [Bug c++/11866] " pinskia at gcc dot gnu dot org
2003-08-11 14:58 ` bangerth at dealii dot org
2003-08-11 19:15 ` Rob_Davies at NTLworld dot com
2003-08-11 21:05 ` bangerth at dealii dot org
2003-08-11 21:06 ` pinskia at gcc dot gnu dot org
2003-08-11 21:28 ` pinskia at gcc dot gnu dot org
2003-08-11 22:32 ` Rob_Davies at NTLworld dot com
2003-12-28 23:08 ` 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).