This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Throwing std::ios_base::failure on formatted input with gcc 6.2
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Edward Diener <eldlistmailingz at tropicsoft dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Oct 2016 11:29:58 +0100
- Subject: Re: Throwing std::ios_base::failure on formatted input with gcc 6.2
- Authentication-results: sourceware.org; auth=none
- References: <nuq4vs$4c5$1@blaine.gmane.org> <CAH6eHdRAhZ0Vsmt1VrpUH_RTFTtgZNYmPOoAMmxA0epQZVGdPw@mail.gmail.com> <CAH6eHdQDp2-j_+HYaa+fBFCB5ZcwSGT1K1fiid6o_gb=aDF4HQ@mail.gmail.com> <nuqbsl$9bu$1@blaine.gmane.org> <CAH6eHdSkL0apuQ8s3m+5KQGcT3PTUJsyaF0ywp=ddC7SQtKeAA@mail.gmail.com> <nuqmkq$j1$1@blaine.gmane.org>
On 26 October 2016 at 17:46, Edward Diener wrote:
> On 10/26/2016 10:57 AM, Jonathan Wakely wrote:
>>
>> On 26 October 2016 at 14:42, Edward Diener wrote:
>>>
>>> I am missing the syntactical difference between the two. There is
>>> 'std::ios_base::failure' and how do you specify the other one ? Your
>>> notation of 'std::ios_base::[abi:__cxx11]failure' I do not understand.
>>>
>>
>> It comes from the abi_tag attribute documented at
>> https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html
>>
>> namespace std {
>> struct ios_base {
>> struct __attribute__((abi__tag__("cxx11"))) failure { };
>> };
>> }
>>
>> I got the demangled name slightly wrong, the attribute goes at the end:
>>
>> #include <iostream>
>> int main()
>> {
>> throw std::ios_base::failure("");
>> }
>> terminate called after throwing an instance of
>> 'std::ios_base::failure[abi:cxx11]'
>> what(): : iostream error
>> Aborted (core dumped)
>
>
> I am syntactically catching 'std::ios::failure'. Are you saying that the
> exception being thrown in my OP is actually
> 'std::ios_base::failure[abi:cxx11]' ? I am still a bit confused when you
> said in a previous reply:
>
>
> "You're trying to catch the new one, but the library throws the old
> one."
I meant exactly that. You're trying to catch the new type, which has a
std::system_error base class and is decorated with
__attribute__((__abi_tag__("cxx11"))), but the library throws the old
type, which is not decorated with the attribute.