delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/05/13:51:56

From: kgc AT user DOT rose DOT com (Keith Carscadden)
Subject: (none)
5 Nov 1998 13:51:56 -0800 :
Message-ID: <3.0.1.32.19981104215232.0069df28.cygnus.gnu-win32@user.rose.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Using B19 release of gdb and gcc, I recently created a program to test a
function that removed trailing blanks from a string, in place. That is, it
moved \0 to the first of one or more trailing blanks. This would change
"123    " to "123" or "a b c   " to "a b c", for example. To test this, I
created a main, created some strings and called the function. This
combination I tested using gdb, and everything appeared to work as I
expected. However, when I ran the program directly from DOS, it aborted
with STATUS_ACCESS_VIOLATION. I eventually realized that the problem was
caused by me passing a pointer to a literal (  char *test1 = "123    "; ),
rather than a pointer to a character array. When I fixed this ( char
test1[] = "123    "; ), the program ran as expected.

My question is, why did this run without an error under gdb, when it
aborted when run under DOS?


Keith

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019