This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/13900] New: time_put chokes on a trailing %
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jan 2004 17:55:51 -0000
- Subject: [Bug libstdc++/13900] New: time_put chokes on a trailing %
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The expected output of the program below is "Sun Jan 0 00:00:00 1900 %".
Instead, when compiled with gcc 3.3.2, the program dumps core. When it
encounters the trailing '%' in the format string, the time_put::do_put() member
function fails to check to see if it happens to be the last character and ends
up incrementing right past it (line 1986 of locale_facets.tcc).
Regards
Martin
#include <ctime>
#include <iostream>
#include <locale>
int main ()
{
const std::time_put<char> &tp =
std::use_facet<std::time_put<char> >(std::locale::classic ());
std::tm tmb = { };
const char fmt[] = "%c %";
tp.put (std::ostreambuf_iterator<char>(std::cout.rdbuf ()),
std::cout, ' ', &tmb, fmt, fmt + sizeof fmt - 1);
std::cout << '\n';
}
--
Summary: time_put chokes on a trailing %
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: all
GCC host triplet: all
GCC target triplet: all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13900