| 1 |
// PR debug/43290 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-O2" } |
| 4 |
// { dg-options "-O3 -mavx -fPIC -mtune=core2" { target { { i?86-*-* x86_64-*-* } && { ilp32 && fpic } } } } |
| 5 |
|
| 6 |
namespace std |
| 7 |
{ |
| 8 |
template <class> struct char_traits; |
| 9 |
} |
| 10 |
typedef struct { union { char __wchb[4]; }; } mbstate_t; |
| 11 |
namespace std |
| 12 |
{ |
| 13 |
template <typename _StateT> struct fpos |
| 14 |
{ |
| 15 |
long long _M_off; |
| 16 |
_StateT _M_state; |
| 17 |
fpos (long long):_M_off (), _M_state () { } |
| 18 |
_StateT state () { return _M_state; } |
| 19 |
}; |
| 20 |
typedef fpos <mbstate_t> streampos; |
| 21 |
} |
| 22 |
namespace std |
| 23 |
{ |
| 24 |
template <> struct char_traits <char> |
| 25 |
{ |
| 26 |
typedef streampos pos_type; |
| 27 |
typedef long long off_type; |
| 28 |
typedef mbstate_t state_type; |
| 29 |
}; |
| 30 |
} |
| 31 |
struct pthread_mutex_t; |
| 32 |
namespace |
| 33 |
{ |
| 34 |
enum _Ios_Openmode { _S_in = 3, _S_out }; |
| 35 |
enum _Ios_Seekdir { _S_beg }; |
| 36 |
struct ios_base |
| 37 |
{ |
| 38 |
typedef _Ios_Openmode openmode; |
| 39 |
static const openmode in = _S_in; |
| 40 |
static const openmode out = _S_out; |
| 41 |
typedef _Ios_Seekdir seekdir; |
| 42 |
static const seekdir beg = _S_beg; |
| 43 |
}; |
| 44 |
template < typename _CharT, typename > struct basic_streambuf |
| 45 |
{ |
| 46 |
typedef _CharT char_type; |
| 47 |
char_type * _M_in_beg; |
| 48 |
char_type *eback () { return _M_in_beg; } |
| 49 |
char_type *gptr () { return 0; } |
| 50 |
}; |
| 51 |
} |
| 52 |
namespace std |
| 53 |
{ |
| 54 |
typedef struct pthread_mutex_t __c_lock; |
| 55 |
template <typename> class __basic_file; |
| 56 |
template <> struct __basic_file <char> |
| 57 |
{ |
| 58 |
__basic_file (__c_lock * = 0); |
| 59 |
bool is_open (); |
| 60 |
}; |
| 61 |
template <typename _CharT, typename _Traits> struct basic_filebuf : public basic_streambuf <_CharT, _Traits> |
| 62 |
{ |
| 63 |
typedef _CharT char_type; |
| 64 |
typedef _Traits traits_type; |
| 65 |
typedef typename traits_type::pos_type pos_type; |
| 66 |
typedef typename traits_type::off_type off_type; |
| 67 |
typedef __basic_file < char >__file_type; |
| 68 |
typedef typename traits_type::state_type __state_type; |
| 69 |
__file_type _M_file; |
| 70 |
char_type *_M_pback_cur_save; |
| 71 |
bool _M_pback_init; |
| 72 |
void _M_destroy_pback () throw () |
| 73 |
{ |
| 74 |
_M_pback_cur_save += this->gptr () != this->eback (); |
| 75 |
_M_pback_init = false; |
| 76 |
} |
| 77 |
bool is_open () throw () { return _M_file.is_open (); } |
| 78 |
pos_type seekpos (pos_type, ios_base::openmode = ios_base::in | ios_base::out); |
| 79 |
pos_type _M_seek (off_type, ios_base::seekdir, __state_type); |
| 80 |
}; |
| 81 |
template <typename _CharT, typename _Traits> |
| 82 |
typename basic_filebuf <_CharT, _Traits>::pos_type |
| 83 |
basic_filebuf <_CharT, _Traits>::seekpos (pos_type __pos, ios_base::openmode) |
| 84 |
{ |
| 85 |
pos_type __ret = (off_type ()); |
| 86 |
if (this->is_open ()) |
| 87 |
{ |
| 88 |
_M_destroy_pback (); |
| 89 |
__ret = _M_seek (off_type (), ios_base::beg, __pos.state ()); |
| 90 |
} |
| 91 |
return __ret; |
| 92 |
} |
| 93 |
template class basic_filebuf <char, char_traits <char> >; |
| 94 |
} |