This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11866] New: poor diagnostic on undeclared exception


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]