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 6549363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:05:02+00:00 2026-05-25T12:05:02+00:00

I have fed the following code through a static analysis tool: u1 = (u1

  • 0

I have fed the following code through a static analysis tool:

u1 = (u1 ^ u2); // OK

u1 = (u1 ^ u2) & u3;  // NOT OK

u1 = (u1 ^ u2) & 10; // NOT OK

u1 = (u1 ^ u2) & 10U; // NOT OK

u1 = (unsigned char)(u1 ^ u2) & 10U; // OK

u1 = (unsigned char)(u1 ^ u2) & u3;  // OK

“OK” means the static analysis tool did not complain.
“NOT OK” means the static analysis tool did complain — claiming that some operand of a bitwise operation is not an unsigned integer.

The results from the last 2 lines show that the parentheses are causing either

a. an actual type conversion to signed

b. something that the static analysis tool thinks is a type conversion to signed

I will ask the static analysis tool developer about (b).

But before I do, I would like to know if perhaps the C language is known to do (a)?

  • 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-25T12:05:02+00:00Added an answer on May 25, 2026 at 12:05 pm

    Nothing in C is done below int: eg when adding two unsigned chars, even before the addition, the operands are converted to int according to the default promotions.

    unsigned char u1, u2, u3;
    u1 = 0;
    u2 = 42;
    u3 = u1 + u2;
    

    In the last line, first u1 and u2 are converted to int, then the + operator is applied to obtain a int value and then that value is converted back to unsigned char (of course the compiler can use shortcuts!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At this present point in time I have some code that does the following:
I have the following code which is supposed to increment a field value by
I have the following code I wrote: Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29); IndexWriter writer
I have a specific Silverlight application, that is fed with data by a WCF-Service.
I have written a simple brainfuck interpreter in MATLAB script language. It is fed
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a UITableViewController that is fed by a NSFetchedResultsController . Everything worked fine,
I have a list that is being fed in to my page using an
I have this piece of SQL that is being fed to Mysql. CREATE TABLE

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.