Bug 69372 - GCC allows array and function types to be caught by reference.
Summary: GCC allows array and function types to be caught by reference.
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 112471 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-01-20 03:32 UTC by Eric Fiselier
Modified: 2023-11-10 04:30 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-05 00:00:00


Attachments
reproducer for array types (364 bytes, text/plain)
2016-01-20 03:32 UTC, Eric Fiselier
Details
reproducer for function types (431 bytes, text/plain)
2016-01-20 03:33 UTC, Eric Fiselier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Fiselier 2016-01-20 03:32:11 UTC
Created attachment 37396 [details]
reproducer for array types

The current C++ draft states:

[expr.throw]/p2 states:
> Evaluating a throw-expression with an operand throws an exception (15.1); the type of the exception object
> is determined by removing any top-level cv-qualifiers from the static type of the operand and adjusting the
> type from “array of T” or function type T to “pointer to T”.

Therefore it should not be possible to catch a function or array by reference. However GCC allows this.
Comment 1 Eric Fiselier 2016-01-20 03:33:42 UTC
Created attachment 37397 [details]
reproducer for function types

attached a reproducer for function types.
Comment 2 Andrew Pinski 2021-08-05 00:54:24 UTC
Confirmed. ICC and clang does not assert in both cases.
Comment 3 Andrew Pinski 2023-11-10 04:30:15 UTC
*** Bug 112471 has been marked as a duplicate of this bug. ***