Patchwork [v3] libstdc++/57920

login
register
mail settings
Submitter Chung-Ju Wu
Date July 23, 2013, 9:17 a.m.
Message ID <CADj25HPZQNgAMm4abc3_c6-vM22U4hCMWW6Q_-Dk0iKFvQ0EPg@mail.gmail.com>
Download mbox | patch
Permalink /patch/261000/
State New
Headers show

Comments

Chung-Ju Wu - July 23, 2013, 9:17 a.m.
2013/7/22 Paolo Carlini <paolo.carlini@oracle.com>:
> Hi,
>
> see audit trail for details. I tested on x86_64-linux (with/without
> _GLIBCXX_X86_RDRAND artificially undefined) the below straightforward patch
> and checked by hand the strace. I'm going to apply it soon.
>
> Thanks,
> Paolo.
>
> ///////////////////

Hi, Paolo,

In this patch I can see that you thought cstdio is unnecessary:



However, for some cases the file libstdc++-v3/include/std/random
may include libstdc++-v3/include/bits/random.h, in which there is
a declaration using FILE type:

[libstdc++-v3/include/std/random]

 46 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 47
 48 #include <cstdint> // For uint_fast32_t, uint_fast64_t, uint_least32_t
 49 #include <bits/random.h>
 50 #include <bits/opt_random.h>
 51 #include <bits/random.tcc>
 52
 53 #endif // _GLIBCXX_USE_C99_STDINT_TR1

[libstdc++-v3/include/bits/random.h]

1639     union
1640     {
1641     FILE*        _M_file;
1642     mt19937      _M_mt;
1643   };

causing the following error:
  libstdc++-v3/include/bits/random.h:1641:5: error: 'FILE' does not name a type
       FILE*        _M_file;

Perhaps cstdio is necessary in this case.  What do you think? :-)


Best regards,
jasonwucj
Paolo Carlini - July 23, 2013, 9:26 a.m.
Hi,

On 07/23/2013 11:17 AM, Chung-Ju Wu wrote:
> 2013/7/22 Paolo Carlini <paolo.carlini@oracle.com>:
>> Hi,
>>
>> see audit trail for details. I tested on x86_64-linux (with/without
>> _GLIBCXX_X86_RDRAND artificially undefined) the below straightforward patch
>> and checked by hand the strace. I'm going to apply it soon.
>>
>> Thanks,
>> Paolo.
>>
>> ///////////////////
> [libstdc++-v3/include/bits/random.h]
>
> 1639     union
> 1640     {
> 1641     FILE*        _M_file;
> 1642     mt19937      _M_mt;
> 1643   };
>
> causing the following error:
>    libstdc++-v3/include/bits/random.h:1641:5: error: 'FILE' does not name a type
>         FILE*        _M_file;
>
> Perhaps cstdio is necessary in this case.  What do you think? :-)
The issue is theoretical at the moment because <string> ends up 
including <cstdio> anyway, thus the above can't really happen. It's true 
that the above union - which by way I didn't invent - it's rather 
annoying if we manage to *really* avoid including <cstdio>, which is 
very big.

Currently you can't really get the error above.

Paolo.
Paolo Carlini - July 23, 2013, 9:33 a.m.
On 07/23/2013 11:26 AM, Paolo Carlini wrote:
> Currently you can't really get the error above.
Ah Ok, now I see when it can happen, not on Linux, it can happen when 
string_conversions.h aren't available. Ok, I'll add back the include 
momentarily.

Paolo.
Chung-Ju Wu - July 23, 2013, 9:47 a.m.
2013/7/23 Paolo Carlini <paolo.carlini@oracle.com>:
> On 07/23/2013 11:26 AM, Paolo Carlini wrote:
>>
>> Currently you can't really get the error above.
>
> Ah Ok, now I see when it can happen, not on Linux, it can happen when
> string_conversions.h aren't available. Ok, I'll add back the include
> momentarily.
>
> Paolo.

Yes, the problem happened when I was building an elf toolchain.
Thank you so much to take a look at this issue. :-)


Best regards,
jasonwucj

Patch

Index: include/std/random
================================================
--- include/std/random	(revision 201122)
+++ include/std/random	(working copy)
@@ -36,7 +36,6 @@ 
 #else

 #include <cmath>
-#include <cstdio>
 #include <cstdlib>
 #include <string>
 #include <iosfwd>