| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2003, 2009 Free Software Foundation | |
| 2 // | |
| 3 // This file is part of the GNU ISO C++ Library. This library is free | |
| 4 // software; you can redistribute it and/or modify it under the | |
| 5 // terms of the GNU General Public License as published by the | |
| 6 // Free Software Foundation; either version 3, or (at your option) | |
| 7 // any later version. | |
| 8 | |
| 9 // This library is distributed in the hope that it will be useful, | |
| 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 // GNU General Public License for more details. | |
| 13 | |
| 14 // You should have received a copy of the GNU General Public License along | |
| 15 // with this library; see the file COPYING3. If not see | |
| 16 // <http://www.gnu.org/licenses/>. | |
| 17 | |
| 18 // 22.2.5.3.1 time_put members | |
| 19 | |
| 20 #include <locale> | |
| 21 #include <sstream> | |
| 22 #include <ctime> | |
| 23 #include <testsuite_hooks.h> | |
| 24 | |
| 25 class TP : public std::time_put<wchar_t> | |
| 26 { | |
| 27 public: | |
| 28 mutable std::string format_chars; | |
| 29 | |
| 30 protected: | |
| 31 iter_type do_put(iter_type s, std::ios_base&, char_type, | |
| 32 const std::tm*, char format, char) const | |
| 33 { | |
| 34 format_chars.push_back(format); | |
| 35 return s; | |
| 36 } | |
| 37 }; | |
| 38 | |
| 39 // libstdc++/12439 | |
| 40 // time_put::put reads past end of format string | |
| 41 void test03() | |
| 42 { | |
| 43 using namespace std; | |
| 44 bool test __attribute__((unused)) = true; | |
| 45 | |
| 46 wostringstream stream; | |
| 47 time_t tt = time(NULL); | |
| 48 | |
| 49 const wchar_t* fmt = L"%c"; | |
| 50 | |
| 51 TP tp; | |
| 52 tp.put(TP::iter_type(stream), stream, stream.fill(), localtime(&tt), | |
| 53 fmt, fmt + 1); | |
| 54 VERIFY( tp.format_chars.empty() ); | |
| 55 } | |
| 56 | |
| 57 int main() | |
| 58 { | |
| 59 test03(); | |
| 60 return 0; | |
| 61 } | |
| OLD | NEW |