From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31632 invoked by alias); 5 Aug 2012 15:03:04 -0000 Received: (qmail 31577 invoked by uid 22791); 5 Aug 2012 15:03:02 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_LG,TW_LP 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; Sun, 05 Aug 2012 15:02:49 +0000 From: "lirex.software at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not. Date: Sun, 05 Aug 2012 15:03:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lirex.software at gmail dot com 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-08/txt/msg00259.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54180 Bug #: 54180 Summary: a bug using strcat function - it depends on variable declare order, but it should not. Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: lirex.software@gmail.com Created attachment 27940 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27940 source file Hello, I want to report bugs: I using gcc gcc-4.6.1 on Microsoft Windows XP (service pack 3) the options of the compiler: c++ -I"D:\Program Files\PostgreSQL\9.1\include" -L"D:\Program Files\PostgreSQL\9.1\lib" -lpq -o %application_file% %application_file%.cpp -Wl,--subsystem,windows -lgdi32 -lcomctl32 -D_WIN32_IE=0x0300 the complete command line that triggers the bug: just a part of my code which handles a window key pressure the compiler output (error messages, warnings, etc.); and: it outputs not the value which is expected, but partially(!) the value of other variable: if it should display a date with SQL_date_begin it displays a part of SQL1 (I replaced almost everywhere the parrword needed to access my Postgre SQL database) the function strcat works only proper if I declare char variables as follow: CHAR SQL_date_begin[10], SQL_date_end[10],SQL1[150], SQL_result[100]; but no way if: CHAR SQL1[150], SQL_date_begin[10], SQL_date_end[10], SQL_result[100]; somewhy in second order it owerwrites value of SQL_date_begin note: to form the value of SQL_date_begin I use strcpy(SQL_date_begin,""); wsprintf(chBuffer,_T("%d"),date_time_begin.wYear); strcat(SQL_date_begin,chBuffer); strcat(SQL_date_begin,"-"); ...(only a part) Regards, Denis Kolesnik.