delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/26/11:55:09

From: Vincent DOT S DOT Perun AT jpl DOT nasa DOT gov (Vincent S. Perun)
Subject: Re: B19.1: memcpy bug (NT)
26 Aug 1998 11:55:09 -0700 :
Message-ID: <Pine.SOL.3.91.980824060331.13242A-100000.cygnus.gnu-win32@object.jpl.nasa.gov>
References: <Pine DOT SOL DOT 3 DOT 91 DOT 980821074602 DOT 26659A-100000 AT object DOT jpl DOT nasa DOT gov>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hello, everyone: I got the message!  The bug was in my internal processor
(grey matter).  It must be time for a vacation.  I know better:  I used to
work with DEC VAX machines which are also little endian.  I've been staring
into the SUNs too long!

Vincent Perun

On Fri, 21 Aug 1998, Vincent S. Perun wrote:

> Hello.  I've discovered a bug with memcpy under beta 19.1 and NT 4.0.  It
> seems the contents of a char array don't copy into an int in the right order:
> The bytes are reversed!  This test expects the output to be "ABCD" but it
> puts out "CDAB".  A char to char memcpy works just fine!
> 
> Vincent Perun
> 
> Test program:
> 
> main()
> {
>    unsigned char s1[2] = {0xAB, 0xCD};
>    unsigned short n;
>    unsigned char s2[2];
> 
>    memcpy (&n, &s1, 2);
>    printf ("n: %4.4X\n", n);
>    memcpy (&s2, &s1, 2);
>    printf ("s2: %2.2X%2.2X\n", s2[0], s2[1]);
> }
> 
-
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