public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/52540] New: std::use_facet throws bad_cast when compiled with _GLIBCXX_DEBUG
@ 2012-03-09 10:56 pluto at agmk dot net
  2012-03-09 11:03 ` [Bug libstdc++/52540] " paolo.carlini at oracle dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: pluto at agmk dot net @ 2012-03-09 10:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52540

             Bug #: 52540
           Summary: std::use_facet throws bad_cast when compiled with
                    _GLIBCXX_DEBUG
    Classification: Unclassified
           Product: gcc
           Version: 4.6.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pluto@agmk.net
            Target: x86_64-w64-mingw32


#include <iostream>
#include <locale>
#include <cstring>
#include <ctime>

int main()
{
        std::tm tm;
        std::time_t tt;
        std::time( &tt );
        tm = *std::localtime( &tt );
        std::locale lc( "C" );
        std::cout.imbue( lc );
        std::time_put< char > const& timeFacet = std::use_facet< std::time_put<
char > >( std::cout.getloc() );
        char const pattern[] = "%x %X";
        timeFacet.put( std::cout, std::cout, std::cout.fill(), &tm, pattern,
pattern + std::strlen( pattern ) );
}

$ x86_64-w64-mingw32-g++ main.cpp -o main-release.exe -g2
$ x86_64-w64-mingw32-g++ main.cpp -o main-debug.exe -g2 -D_GLIBCXX_DEBUG

release-run:

Starting program: main-release.exe
[New Thread 2776.0xdbc]

Breakpoint 1, main () at main.cpp:7
7       {
(gdb) n
10              std::time( &tt );
(gdb)
11              tm = *std::localtime( &tt );
(gdb)
12              std::locale lc( "C" );
(gdb)
13              std::cout.imbue( lc );
(gdb) p lc
$2 = {static none = 0, static ctype = 1, static numeric = 2, static collate =
4, static time = 8, static monetary = 16,
  static messages = 32, static all = 63, _M_impl = 0x626e9460, static
_S_classic = 0x626e9460, static _S_global = 0x626e9460,
  static _S_categories = 0x626eadc0, static _S_once = {done = 1, started = 0}}
(gdb) c
Continuing.
03/09/12 11:53:50
Program exited normally.


debug-run:

Starting program: main-debug.exe
[New Thread 2704.0xd4c]

Breakpoint 1, main () at main.cpp:7
7       {
(gdb) l
2       #include <locale>
3       #include <cstring>
4       #include <ctime>
5
6       int main()
7       {
8               std::tm tm;
9               std::time_t tt;
10              std::time( &tt );
11              tm = *std::localtime( &tt );
(gdb) n
10              std::time( &tt );
(gdb)
11              tm = *std::localtime( &tt );
(gdb)
12              std::locale lc( "C" );
(gdb)
13              std::cout.imbue( lc );
(gdb) p lc
$1 = {static none = 0, static ctype = 1, static numeric = 2, static collate =
4, static time = 8, static monetary = 16,
  static messages = 32, static all = 63, _M_impl = 0x626e9460, static
_S_classic = 0x626e9460, static _S_global = 0x626e9460,
  static _S_categories = 0x626eadc0, static _S_once = {done = 1, started = 0}}
(gdb) n
14              std::time_put< char > const& timeFacet = std::use_facet<
std::time_put< char > >( std::cout.getloc() );
(gdb)
terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-03-23 11:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09 10:56 [Bug libstdc++/52540] New: std::use_facet throws bad_cast when compiled with _GLIBCXX_DEBUG pluto at agmk dot net
2012-03-09 11:03 ` [Bug libstdc++/52540] " paolo.carlini at oracle dot com
2012-03-09 11:20 ` ktietz at gcc dot gnu.org
2012-03-09 11:21 ` ktietz at gcc dot gnu.org
2012-03-09 12:00 ` ktietz at gcc dot gnu.org
2012-03-09 12:56 ` paolo.carlini at oracle dot com
2012-03-09 13:01 ` ktietz at gcc dot gnu.org
2012-03-10 13:15 ` pluto at agmk dot net
2012-03-10 13:17 ` pluto at agmk dot net
2012-03-11 11:21 ` paolo.carlini at oracle dot com
2012-03-11 18:36 ` ktietz at gcc dot gnu.org
2012-03-11 19:50 ` pluto at agmk dot net
2012-03-15 16:23 ` pluto at agmk dot net
2012-03-15 16:37 ` pluto at agmk dot net
2012-03-16 10:12 ` paolo.carlini at oracle dot com
2012-03-16 10:40 ` pluto at agmk dot net
2012-03-19 23:59 ` paolo at gcc dot gnu.org
2012-03-23 11:09 ` paolo at gcc dot gnu.org
2012-03-23 11:33 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).