This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: c_std/ and throw()
Jakub Jelinek <jakub@redhat.com> wrote:
>
> ??
> Adding throw() (note the empty list) means the function cannot throw any
> exceptions, which means g++ can count on this.
Yep. You are right.
calling function marked with throw() (for gcc 2.96):
Sections:
Idx Name Size VMA LMA File off Algn
4 .text.f__Fv 0000002b 00000000 00000000 00000048 2**2
5 .eh_frame 00000038 00000000 00000000 00000074 2**2
without throw:
use_bar.o: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
4 .text.b__Fv 0000004d 00000000 00000000 00000048 2**2
5 .gcc_except_table 0000002c 00000000 00000000 00000098 2**2
6 .eh_frame 00000040 00000000 00000000 000000c4 2**2
> And the vast majority of glibc functions cannot throw any exceptions, it is
> C code compiled with -fno-exceptions. The exceptions in glibc are functions
> like qsort or bsearch which take function pointer argument, which could be
> written in C++ and throw exceptions. These functions are compiled with
> -fexceptions and have no throw() at their prototypes in glibc headers.
>
Yep. This is clear win to mark function as throw() if it is a leaf function
or calls only functions also marked as throw(). In other cases, the
situation is not so clear.
Best regards,
Artem.