public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111681] New: Missing fixit for exception name in catch
@ 2023-10-03 16:18 sjames at gcc dot gnu.org
  2023-10-03 22:29 ` [Bug c++/111681] better error message for unknown type " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-10-03 16:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111681

            Bug ID: 111681
           Summary: Missing fixit for exception name in catch
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
                CC: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Noticed with a Blender issue w/ GCC 13 (missing transitive include for
<system_error>, https://bugs.gentoo.org/914740).

If I just take the example at
https://en.cppreference.com/w/cpp/error/system_error and mangle it, I get:
```
#include <thread>

int main()
{
    try
    {
        std::thread().detach(); // attempt to detach a non-thread
    }
    catch(const std::system_error& e)
    {
        std::cout << "Caught system_error with code "
                     "[" << e.code() << "] meaning "
                     "[" << e.what() << "]\n";
    }
}
```

with:
```
$ g++-14 /tmp/foo.cxx -o /tmp/foo
/tmp/foo.cxx: In function ‘int main()’:
/tmp/foo.cxx:9:34: error: expected unqualified-id before ‘&’ token
    9 |     catch(const std::system_error& e)
      |                                  ^
/tmp/foo.cxx:9:34: error: expected ‘)’ before ‘&’ token
    9 |     catch(const std::system_error& e)
      |          ~                       ^
      |                                  )
/tmp/foo.cxx:9:34: error: expected ‘{’ before ‘&’ token
/tmp/foo.cxx:9:36: error: ‘e’ was not declared in this scope
    9 |     catch(const std::system_error& e)
      |                                    ^
```

The error message here could be better, but even better would be a fixit saying
to include <system_error>.

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

* [Bug c++/111681] better error message for unknown type in catch
  2023-10-03 16:18 [Bug c++/111681] New: Missing fixit for exception name in catch sjames at gcc dot gnu.org
@ 2023-10-03 22:29 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-03 22:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111681

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
            Summary|Missing fixit for exception |better error message for
                   |name in catch               |unknown type in catch
           Severity|normal                      |enhancement
   Last reconfirmed|                            |2023-10-03
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
confirmed.

Even:
```
namespace tt{}
int main()
{
    try
    {    }
    catch(const tt::xxxx& e)
    {    }
}
```

Should give a better error message where xxxx is an unknown type in `namespace
tt`.

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

end of thread, other threads:[~2023-10-03 22:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 16:18 [Bug c++/111681] New: Missing fixit for exception name in catch sjames at gcc dot gnu.org
2023-10-03 22:29 ` [Bug c++/111681] better error message for unknown type " pinskia at gcc dot gnu.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).