public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not.
@ 2012-08-05 15:03 lirex.software at gmail dot com
  2012-08-05 15:08 ` [Bug c++/54180] " lirex.software at gmail dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-05 15:03 UTC (permalink / raw)
  To: gcc-bugs

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.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
@ 2012-08-05 15:08 ` lirex.software at gmail dot com
  2012-08-05 15:11 ` lirex.software at gmail dot com
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-05 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-05 15:08:35 UTC ---
Created attachment 27941
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27941
additional files to source asked


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
  2012-08-05 15:08 ` [Bug c++/54180] " lirex.software at gmail dot com
@ 2012-08-05 15:11 ` lirex.software at gmail dot com
  2012-08-05 15:12 ` schwab@linux-m68k.org
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-05 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-05 15:10:47 UTC ---
Created attachment 27942
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27942
object file to source

all files modified in an text editor to change password - so it size may vary


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
  2012-08-05 15:08 ` [Bug c++/54180] " lirex.software at gmail dot com
  2012-08-05 15:11 ` lirex.software at gmail dot com
@ 2012-08-05 15:12 ` schwab@linux-m68k.org
  2012-08-05 15:13 ` lirex.software at gmail dot com
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: schwab@linux-m68k.org @ 2012-08-05 15:12 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> 2012-08-05 15:12:07 UTC ---
You are writing past array bounds.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (2 preceding siblings ...)
  2012-08-05 15:12 ` schwab@linux-m68k.org
@ 2012-08-05 15:13 ` lirex.software at gmail dot com
  2012-08-09 23:19 ` lirex.software at gmail dot com
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-05 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-05 15:12:58 UTC ---
Created attachment 27943
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27943
asm file as addition to the source


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (3 preceding siblings ...)
  2012-08-05 15:13 ` lirex.software at gmail dot com
@ 2012-08-09 23:19 ` lirex.software at gmail dot com
  2012-08-09 23:22 ` pinskia at gcc dot gnu.org
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-09 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #5 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-09 23:19:16 UTC ---
The syntax of the programming language "C++" includes the syntax of the
programming language "C"
and also it should handle such common functions as "strcat". 

So if I define variables in a such way:

CHAR SQL1[150], SQL2[150], SQL_date_payment[10], SQL_date_begin[10],
SQL_date_end[10],  SQL_result[100];   

instead of:

CHAR SQL_date_payment[10],SQL_date_begin[10], SQL_date_end[10], SQL1[150],
SQL2[150], SQL_result[100];   

(where variables for dates which I form using "strcpy" and "strcat" functions
stay after SQL1)

it should work without problems, because of programming language syntax which
is a standart.
But it works so, that SQL1 partially overwrites value of SQL_date_begin and
values are
not such as expected.


I never heard, that the "C" language is outdated. The "C++" is just another
standart which includes
the syntax of "C".

So I consider it is as an GCC error which should be fixed, also because all
standart libraries
come along with GCC.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (4 preceding siblings ...)
  2012-08-09 23:19 ` lirex.software at gmail dot com
@ 2012-08-09 23:22 ` pinskia at gcc dot gnu.org
  2012-08-09 23:33 ` lirex.software at gmail dot com
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-08-09 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-08-09 23:22:22 UTC ---
The order of the variables is not the issue.  The issue is you are writing past
the array bounds of the variables which is undefined.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (5 preceding siblings ...)
  2012-08-09 23:22 ` pinskia at gcc dot gnu.org
@ 2012-08-09 23:33 ` lirex.software at gmail dot com
  2012-08-09 23:35 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-09 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #7 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-09 23:33:15 UTC ---
all those variables are defined, otherwise it would not compile. The main is,
that it is normal(both cases) for the "C" language syntax and both declaration
orders should work.

That is why it is a bug.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (6 preceding siblings ...)
  2012-08-09 23:33 ` lirex.software at gmail dot com
@ 2012-08-09 23:35 ` pinskia at gcc dot gnu.org
  2012-08-10 14:16 ` lirex.software at gmail dot com
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-08-09 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-08-09 23:35:06 UTC ---
(In reply to comment #7)
> all those variables are defined, otherwise it would not compile. The main is,
> that it is normal(both cases) for the "C" language syntax and both declaration
> orders should work.

With the correct lengths?  Writing past the array bounds in both C and C++ is
not required a diagnostic, it just invokes undefined behavior.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (7 preceding siblings ...)
  2012-08-09 23:35 ` pinskia at gcc dot gnu.org
@ 2012-08-10 14:16 ` lirex.software at gmail dot com
  2012-08-10 14:51 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-10 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #9 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-10 14:16:34 UTC ---
With any length(a length which is declared is of accepted range) it considered
as a variable, so it should be processed whithout dependance on
declare order.

Functions strcpy and strcat should handle so a CHAR array variable
as it is a line which ends correspondly. They even do, but not in any declare
order. They should do in in any declare order.

It is a bug anyway.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (8 preceding siblings ...)
  2012-08-10 14:16 ` lirex.software at gmail dot com
@ 2012-08-10 14:51 ` redi at gcc dot gnu.org
  2012-08-10 15:04 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-10 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-10 14:51:15 UTC ---
Your bug report is useless, you have not provided the information requested at
http://gcc.gnu.org/bugs/ so it cannot be compiled or verified, and your
description of the problem is hard to follow.

The problem is that your array is too small for the data you write to the
array. This has nothing to do with the order of declarations.

You declare SQL1[150] then you call

strcat(SQL1,"select id,' ', to_char(dt_date,'DD.MM.YYYY'),' ',int_from,'
','>',' ',int_to,' ',cur_amount,' ',(select str_comment from
tbl_dic_payment_types where tbl_dic_payment_types.id=tbl_bills.int_type) as
type,' ', (select case when int_type=1 then 'business' else 'personal' end from
tbl_bills_entity_type where tbl_bills_entity_type.int_bill=tbl_bills.id) as
test2 from tbl_bills ");

That's more than 150 characters. Your program has a bug, not GCC.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (9 preceding siblings ...)
  2012-08-10 14:51 ` redi at gcc dot gnu.org
@ 2012-08-10 15:04 ` redi at gcc dot gnu.org
  2012-08-16 22:26 ` schwab@linux-m68k.org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-10 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-10 15:04:10 UTC ---
Also, you declare SQL_date_begin[10] then fill it with 11 characters
(YYYY-MM-DD plus the numm terminator) and do the same with SQL_date_end

This is horrible, horrible code and should be deleted immediately.

(In reply to comment #5)
> it should work without problems, because of programming language syntax which
> is a standart.
> But it works so, that SQL1 partially overwrites value of SQL_date_begin and
> values are
> not such as expected.

Please check the standard before arguing about it. The C standard states that
for the functions in <string.h> "If an array is accessed beyond the end of an
object, the behavior is undefined."  

To understand undefined behaviour see:
http://en.wikipedia.org/wiki/Undefined_behavior


> I never heard, that the "C" language is outdated. The "C++" is just another
> standart which includes
> the syntax of "C".

Noone said it's outdated, what on earth are you talking about?

> So I consider it is as an GCC error which should be fixed, also because all
> standart libraries
> come along with GCC.

No, the strcat and strcpy functions come from the C library provided by your
OS, they do not come from GCC. If you still believe there is a bug then maybe
you should report it to Microsoft instead.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (10 preceding siblings ...)
  2012-08-10 15:04 ` redi at gcc dot gnu.org
@ 2012-08-16 22:26 ` schwab@linux-m68k.org
  2012-08-16 22:35 ` lirex.software at gmail dot com
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: schwab@linux-m68k.org @ 2012-08-16 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andreas Schwab <schwab@linux-m68k.org> 2012-08-16 22:26:11 UTC ---
*** Bug 54291 has been marked as a duplicate of this bug. ***


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (11 preceding siblings ...)
  2012-08-16 22:26 ` schwab@linux-m68k.org
@ 2012-08-16 22:35 ` lirex.software at gmail dot com
  2012-08-16 23:00 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-16 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #13 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-16 22:35:01 UTC ---
I disagree: 
I know enough to use strcat and strcpy.

1: Why those functions work false and are dependent on variables(! I name it
correct even if it is one dimenision array of chararters) declare order I don't
know.

2: on this site there are enough people with very vary C and C++ language
skills, so this sites helps on learning also. I know too much people who
learner more from wrong experiences rather than from clear imagination.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (12 preceding siblings ...)
  2012-08-16 22:35 ` lirex.software at gmail dot com
@ 2012-08-16 23:00 ` pinskia at gcc dot gnu.org
  2012-08-17  0:03 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-08-16 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-08-16 22:59:51 UTC ---
Can you stop reopening this bug?  The problem again is that you are writing
past the array bounds and anytime that happens it is undefined behavior. 
Please fix the array bounds issue and you will see it works now.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (13 preceding siblings ...)
  2012-08-16 23:00 ` pinskia at gcc dot gnu.org
@ 2012-08-17  0:03 ` redi at gcc dot gnu.org
  2012-08-18 21:16 ` lirex.software at gmail dot com
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-17  0:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-17 00:03:17 UTC ---
(In reply to comment #13)
> I disagree: 
> I know enough to use strcat and strcpy.

That's provably false.

> 1: Why those functions work false and are dependent on variables(! I name it
> correct even if it is one dimenision array of chararters) declare order I don't
> know.
> 
> 2: on this site there are enough people with very vary C and C++ language
> skills, so this sites helps on learning also. I know too much people who
> learner more from wrong experiences rather than from clear imagination.

No, this is not the place to learn how to fix your code, we have better things
to do. Please find a different site.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (14 preceding siblings ...)
  2012-08-17  0:03 ` redi at gcc dot gnu.org
@ 2012-08-18 21:16 ` lirex.software at gmail dot com
  2012-08-18 21:29 ` lirex.software at gmail dot com
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-18 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #16 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-18 21:16:21 UTC ---
(In reply to comment #14)
> Can you stop reopening this bug?  The problem again is that you are writing
> past the array bounds and anytime that happens it is undefined behavior. 
> Please fix the array bounds issue and you will see it works now.

Andrew I did fix my problem, but the program language standard of "C" is
violated.
That is why I consider it is as a bug.

Where I'm wrong here?


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (15 preceding siblings ...)
  2012-08-18 21:16 ` lirex.software at gmail dot com
@ 2012-08-18 21:29 ` lirex.software at gmail dot com
  2012-08-18 22:07 ` lirex.software at gmail dot com
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-18 21:29 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #17 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-18 21:28:56 UTC ---
(In reply to comment #11)
> Also, you declare SQL_date_begin[10] then fill it with 11 characters
> (YYYY-MM-DD plus the numm terminator) and do the same with SQL_date_end
> 
> This is horrible, horrible code and should be deleted immediately.
> 
> (In reply to comment #5)
> > it should work without problems, because of programming language syntax which
> > is a standart.
> > But it works so, that SQL1 partially overwrites value of SQL_date_begin and
> > values are
> > not such as expected.
> 
> Please check the standard before arguing about it. The C standard states that
> for the functions in <string.h> "If an array is accessed beyond the end of an
> object, the behavior is undefined."  
> 
> To understand undefined behaviour see:
> http://en.wikipedia.org/wiki/Undefined_behavior
> 
> 
> > I never heard, that the "C" language is outdated. The "C++" is just another
> > standart which includes
> > the syntax of "C".
> 
> Noone said it's outdated, what on earth are you talking about?
> 
> > So I consider it is as an GCC error which should be fixed, also because all
> > standart libraries
> > come along with GCC.
> 
> No, the strcat and strcpy functions come from the C library provided by your
> OS, they do not come from GCC. If you still believe there is a bug then maybe
> you should report it to Microsoft instead.

thank you for understandable answer!


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (16 preceding siblings ...)
  2012-08-18 21:29 ` lirex.software at gmail dot com
@ 2012-08-18 22:07 ` lirex.software at gmail dot com
  2012-08-18 22:12 ` lirex.software at gmail dot com
  2012-08-18 22:19 ` redi at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-18 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-18 22:07:20 UTC ---
(In reply to comment #10)
> Your bug report is useless, you have not provided the information requested at
> http://gcc.gnu.org/bugs/ so it cannot be compiled or verified, and your
> description of the problem is hard to follow.
> 
> The problem is that your array is too small for the data you write to the
> array. This has nothing to do with the order of declarations.
> 
> You declare SQL1[150] then you call
> 
> strcat(SQL1,"select id,' ', to_char(dt_date,'DD.MM.YYYY'),' ',int_from,'
> ','>',' ',int_to,' ',cur_amount,' ',(select str_comment from
> tbl_dic_payment_types where tbl_dic_payment_types.id=tbl_bills.int_type) as
> type,' ', (select case when int_type=1 then 'business' else 'personal' end from
> tbl_bills_entity_type where tbl_bills_entity_type.int_bill=tbl_bills.id) as
> test2 from tbl_bills ");
> 
> That's more than 150 characters. Your program has a bug, not GCC.

I'm sorry, you are right! The problem was inside my program.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (17 preceding siblings ...)
  2012-08-18 22:07 ` lirex.software at gmail dot com
@ 2012-08-18 22:12 ` lirex.software at gmail dot com
  2012-08-18 22:19 ` redi at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: lirex.software at gmail dot com @ 2012-08-18 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

Denis Kolesnik <lirex.software at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

--- Comment #19 from Denis Kolesnik <lirex.software at gmail dot com> 2012-08-18 22:11:52 UTC ---
I'm sorry it is my falut, which caused undefined behaviour. I declared small
sized variables.


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

* [Bug c++/54180] a bug using strcat function - it depends on variable declare order, but it should not.
  2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
                   ` (18 preceding siblings ...)
  2012-08-18 22:12 ` lirex.software at gmail dot com
@ 2012-08-18 22:19 ` redi at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-18 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-18 22:18:28 UTC ---
*** Bug 54214 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2012-08-18 22:19 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-05 15:03 [Bug c++/54180] New: a bug using strcat function - it depends on variable declare order, but it should not lirex.software at gmail dot com
2012-08-05 15:08 ` [Bug c++/54180] " lirex.software at gmail dot com
2012-08-05 15:11 ` lirex.software at gmail dot com
2012-08-05 15:12 ` schwab@linux-m68k.org
2012-08-05 15:13 ` lirex.software at gmail dot com
2012-08-09 23:19 ` lirex.software at gmail dot com
2012-08-09 23:22 ` pinskia at gcc dot gnu.org
2012-08-09 23:33 ` lirex.software at gmail dot com
2012-08-09 23:35 ` pinskia at gcc dot gnu.org
2012-08-10 14:16 ` lirex.software at gmail dot com
2012-08-10 14:51 ` redi at gcc dot gnu.org
2012-08-10 15:04 ` redi at gcc dot gnu.org
2012-08-16 22:26 ` schwab@linux-m68k.org
2012-08-16 22:35 ` lirex.software at gmail dot com
2012-08-16 23:00 ` pinskia at gcc dot gnu.org
2012-08-17  0:03 ` redi at gcc dot gnu.org
2012-08-18 21:16 ` lirex.software at gmail dot com
2012-08-18 21:29 ` lirex.software at gmail dot com
2012-08-18 22:07 ` lirex.software at gmail dot com
2012-08-18 22:12 ` lirex.software at gmail dot com
2012-08-18 22:19 ` redi at gcc dot gnu.org

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).