------- Comment #18 from david dot kirkby at onetel dot net  2009-07-17 11:19 
-------
(In reply to comment #17)
> Try:
> typedef __SIZE_TYPE__ size_t;
> extern void *memset (void *, const void *, size_t);
> extern void abort (void);
> volatile size_t i = 0x80000000U, j = 0x80000000U;
> char buf[16];
> 
> int main (void)
> {
>   if (sizeof (size_t) != 4)
>     return 0;
>   buf[0] = 6;
>   memset (buf, 0, i + j);
>   if (buf[0] != 6)
>     abort ();
>   return 0;
> }
> In 32-bit code, size_t is 32-bit, memset is called with buf, 0, 0 arguments,
> but the %o2 register passed to it doesn't contain 0, but 0x100000000.  That is
> fine, this is 32-bit code, so the uppermost bits are always undefined.  But
> when 32-bit memset uses brnz %o2, ... instruction, it needs to first
> zero-extend it to 64-bits, as brnz operates on all 64 bits only.  Or not use
> brnz, but compare and be %icc, ...
> 


I've compiled and linked that code. It does not abort. i.e. I do NOT see:
Abort (core dumped).

In 64-bit mode, it issues a warning:

$ gcc -m64  check.c
check.c:2: warning: conflicting types for built-in function 'memset'

but again builds an executable which exits normally. 

If you want the assembler output posted from Tim's preprocessed file, let me
know how to do it and I'll do it, just in case gcc is behaving differently on
this machine to yours.

As I say, if you want an account Jakub, you can have one. Just tell me a user
name. It might be the simplest way for you to look at this. 

Dave 


-- 


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

Reply via email to