Bit shifting versus architecture question.

  • Thread starter Charles Sullivan
  • Start date
C

christian.bau

Then why did the compiler not make a working code for such a missing
instruction? Isn't that a fault of the compiler?

The result of right shifting negative numbers is implementation
defined. If you rely on a specific result and don't get it, that's
your own fault. As a consequence, my code won't ever rely on such a
result (usually right shifting a negative number is a bug in someone's
code anyway). It would be a very bad idea for the compiler writer to
create slower code for _all_ right shifts of integers just to give you
the result that you expect in a situation where you have no right to
expect anything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top