Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx

Felipe Magno de Almeida felipe.m.almeida@gmail.com
Wed Dec 14 21:39:00 GMT 2016


Hello Jonathan,

Sorry for the delay, I was in mid-vacation.

Comments are inline.

On Tue, Dec 6, 2016 at 3:45 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 16/09/16 02:53 -0300, Felipe Magno de Almeida wrote:
>>

[snip]

>> I've tried both approaches. Templates were causing problems of not
>> defined instantations because they were being used as ints too
>> in other _M_extract functions through a tmp integer. And typedef's
>> caused the same problem of having to use a tmp value of the right
>> type but for example _M_extract_wday_or_month could not have the
>> same type (in AVR they do) and I'd have to use a temporary anyway
>> then.
>>
>> This was the least intrusive way.
>
>
> Did you consider something like this?

I have, but I did not like how it could run code that is not very explicit
in case of exceptions, possibly assigning from a non-initialized variable,
causing, theoretically UB. Besides, __mem was already used for
tm_mom, so it seemed best to just mimic for the rest.

I have another patch attached which fixes the problem you mentioned
and the same problem with the tm_wday in a different switch-case.
I've removed all initializations of __mem, the same way that tm_mon
already did not initialize it, because the value is not actually used at
all in extract_num and variants.

I have ran the test and nothing on locale failed, I've ran again with the fixes,
and there are also no errors on locale. Testing with x86_64.

Changelog is:

2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>

   * include/bits/locale_facets_nonio.tcc: Avoid compilation errors
   with non-standard struct tm.

> This should have no overhead for the targets with standard conforming
> struct tm, and only uses a temporary variable and additional
> assignments for AVR.
>
> It's ugly though.

Quite ugly, specially because of exceptions IMO.

Kind regards,
-- 
Felipe Magno de Almeida
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Use-temporary-int-objects-to-access-struct-tm-member.patch
Type: text/x-diff
Size: 4812 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20161214/d5af1b7a/attachment.bin>


More information about the Libstdc++ mailing list