public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions
@ 2022-10-20 18:30 hiraditya at msn dot com
2022-10-20 18:42 ` [Bug libstdc++/107335] " pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: hiraditya at msn dot com @ 2022-10-20 18:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
Bug ID: 107335
Summary: call to throw_bad_cast even with -fno-exceptions
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hiraditya at msn dot com
Target Milestone: ---
Testcase:
#include<iostream>
void foo() {
std::cout << std::endl;
}
$ g++ -std=c++17 -O3 -fno-exceptions
```asm
foo():
mov rax, QWORD PTR std::cout[rip]
push rbx
mov rax, QWORD PTR [rax-24]
mov rbx, QWORD PTR std::cout[rax+240]
test rbx, rbx
je .L10
cmp BYTE PTR [rbx+56], 0
je .L5
movsx esi, BYTE PTR [rbx+67]
.L6:
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >::put(char)
pop rbx
mov rdi, rax
jmp std::basic_ostream<char, std::char_traits<char> >::flush()
.L5:
mov rdi, rbx
call std::ctype<char>::_M_widen_init() const
mov rax, QWORD PTR [rbx]
mov esi, 10
mov rax, QWORD PTR [rax+48]
cmp rax, OFFSET FLAT:_ZNKSt5ctypeIcE8do_widenEc
je .L6
mov rdi, rbx
call rax
movsx esi, al
jmp .L6
.L10:
call std::__throw_bad_cast() <----------- call to __throw_bad_cast
_GLOBAL__sub_I_foo():
sub rsp, 8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
add rsp, 8
jmp __cxa_atexit
```
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
@ 2022-10-20 18:42 ` pinskia at gcc dot gnu.org
2022-10-20 18:50 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-20 18:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-10-20
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
[/opt/compiler-explorer/gcc-trunk-20221020/include/c++/13.0.0/bits/basic_ios.h:50:18]
std::__throw_bad_cast ();
Inside include/bits/basic_ios.h :
template<typename _Facet>
inline const _Facet&
__check_facet(const _Facet* __f)
{
if (!__f)
__throw_bad_cast();
return *__f;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
2022-10-20 18:42 ` [Bug libstdc++/107335] " pinskia at gcc dot gnu.org
@ 2022-10-20 18:50 ` redi at gcc dot gnu.org
2022-10-20 18:52 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-20 18:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
But that's not a throw, it's a function call. If the definition of that
function is compiled without exceptions then it will abort instead of throw.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
2022-10-20 18:42 ` [Bug libstdc++/107335] " pinskia at gcc dot gnu.org
2022-10-20 18:50 ` redi at gcc dot gnu.org
@ 2022-10-20 18:52 ` redi at gcc dot gnu.org
2022-10-20 20:24 ` hiraditya at msn dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-20 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So what exactly is the bug? You want the abort to happen right there? There are
dozens of place we call functions like that instead of throwing.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
` (2 preceding siblings ...)
2022-10-20 18:52 ` redi at gcc dot gnu.org
@ 2022-10-20 20:24 ` hiraditya at msn dot com
2022-10-20 20:27 ` hiraditya at msn dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: hiraditya at msn dot com @ 2022-10-20 20:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
--- Comment #4 from AK <hiraditya at msn dot com> ---
I wasn't sure if this is expected. Thanks for clarifying.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
` (3 preceding siblings ...)
2022-10-20 20:24 ` hiraditya at msn dot com
@ 2022-10-20 20:27 ` hiraditya at msn dot com
2022-10-20 20:30 ` pinskia at gcc dot gnu.org
2022-10-20 20:45 ` hiraditya at msn dot com
6 siblings, 0 replies; 8+ messages in thread
From: hiraditya at msn dot com @ 2022-10-20 20:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
--- Comment #5 from AK <hiraditya at msn dot com> ---
Is this the definition of throw_bad_cast?
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/cp/rtti.c#L221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
` (4 preceding siblings ...)
2022-10-20 20:27 ` hiraditya at msn dot com
@ 2022-10-20 20:30 ` pinskia at gcc dot gnu.org
2022-10-20 20:45 ` hiraditya at msn dot com
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-20 20:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to AK from comment #5)
> Is this the definition of throw_bad_cast?
>
> https://github.com/gcc-mirror/gcc/blob/
> 16e2427f50c208dfe07d07f18009969502c25dc8/gcc/cp/rtti.c#L221
No.
The definition is in libstdc++v3/src/c++11/functexcept.cc .
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/107335] call to throw_bad_cast even with -fno-exceptions
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
` (5 preceding siblings ...)
2022-10-20 20:30 ` pinskia at gcc dot gnu.org
@ 2022-10-20 20:45 ` hiraditya at msn dot com
6 siblings, 0 replies; 8+ messages in thread
From: hiraditya at msn dot com @ 2022-10-20 20:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107335
AK <hiraditya at msn dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #7 from AK <hiraditya at msn dot com> ---
not a bug
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-10-20 20:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 18:30 [Bug c++/107335] New: call to throw_bad_cast even with -fno-exceptions hiraditya at msn dot com
2022-10-20 18:42 ` [Bug libstdc++/107335] " pinskia at gcc dot gnu.org
2022-10-20 18:50 ` redi at gcc dot gnu.org
2022-10-20 18:52 ` redi at gcc dot gnu.org
2022-10-20 20:24 ` hiraditya at msn dot com
2022-10-20 20:27 ` hiraditya at msn dot com
2022-10-20 20:30 ` pinskia at gcc dot gnu.org
2022-10-20 20:45 ` hiraditya at msn dot com
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).