Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:43+00:00 2026-05-26T03:45:43+00:00

What is the difference between *(unsigned*)d = *(unsigned*)s; d+=4; s+=4; *(unsigned*)d = *(unsigned*)s; d+=4;

  • 0

What is the difference between

*(unsigned*)d = *(unsigned*)s; 
d+=4; s+=4; 
*(unsigned*)d = *(unsigned*)s; 
d+=4; s+=4;

and

*(unsigned long*)d = *(unsigned long*)s;
d+=8; s+=8;

on 64bit systems?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:45:44+00:00Added an answer on May 26, 2026 at 3:45 am

    Provided that nothing unpleasant happens in respect of padding bits or strict aliasing rules, and assuming the sizes of the types are as you expect, and provided that the memory regions don’t overlap, and are correctly aligned, then they each copy 8 bytes from one place to another.

    Of course, aside from the practical effect there may be a difference in performance and/or code size.

    If you’re seeing something break, then look at the actual code emitted, that might tell you what has gone wrong. Unless you have a lot of optimization switched on, and maybe even with optimization, I don’t immediately see why those wouldn’t be equivalent with AMD64, Ubuntu, and gcc.

    Things I’ve mentioned that could go wrong:

    • padding bits – doesn’t apply to GCC, but the standard permits unsigned an unsigned long to have padding bits, and if so then there could be bit patterns which are trap representations of one or both, which could explode as soon as you dereference.
    • strict aliasing – unlikely to affect what that code does, but could affect the code you use to check the result. For example, if s and d are the result of casting pointers-to-double to uint8_t*, and you look at the resulting double, then in one or both cases you might not see the effects of the change because you have an illegal type-pun.
    • sizes of the types – shouldn’t apply here since 64 bit linux is LP64, but obviously if sizeof(long) == 4 then the two aren’t equivalent. long is 32 bits on 64bit Windows systems, just not 64bit Linux ones.
    • overlap – if d == s + 4, then the two code snippets have different effect. Because of this, you won’t see the first optimized to become the second unless the compiler knows that d and s point to entirely different places (and that’s what C99 restrict is for).
    • alignment – I can’t remember what the alignment requirements are for x86-64: for x86 you can get away with an unaligned read/write, it’s just slower. In general, if s or d is correctly aligned for int but not long then there’s a difference. (Edit: apparently you can enable or disable hardware exceptions for unaligned access on x86-64).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between unsigned long and UINT64 ? I think they are
Are there any performance difference between decimal(10,0) unsigned type and int(10) unsigned type?
i know unsigned,two's complement, ones' complement and sign magnitude, and the difference between these,
What is the difference between signed and unsigned in MySQL? And what does signed
So I know that the difference between a signed int and unsigned int is
Is there any difference between uint and unsigned int ? I'm looking in this
I understand the difference between unsigned char * and char * types. I also
I know the difference in memory usage between byte, unsigned short, and integer, but
What is the difference between unsigned and unsigned int ? This question was already
Could you please make it clear what the difference is between unsigned and unsigned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.