From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17358 invoked by alias); 9 Mar 2012 10:56:26 -0000 Received: (qmail 17348 invoked by uid 22791); 9 Mar 2012 10:56:24 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Mar 2012 10:56:11 +0000 From: "pluto at agmk dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/52540] New: std::use_facet throws bad_cast when compiled with _GLIBCXX_DEBUG Date: Fri, 09 Mar 2012 10:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pluto at agmk dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg00728.txt.bz2 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 #include #include #include 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 3 #include 4 #include 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