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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:42:27+00:00 2026-05-25T16:42:27+00:00

Background The last time I asked about whether parentheses were causing implicit cast (

  • 0

Background

The last time I asked about whether parentheses were causing implicit cast (here), @pmg was nice enough to point out that “Nothing in C is done below int” But there, the discussion was about bitwise operators, and the parentheses turned out to be just a distraction.

Introduction

Below, the parentheses are the main attraction. Or, to be more boring but precise, the only operators I see are the parentheses and assignment operators.

At this reference about the C parentheses operator, I do not see anything about parentheses changing the type (outside of typecast syntax, which is not this case).

Meanwhile, here’s a reference that reminds that there is automatic type conversion on assignment, but I don’t think that will explain the static analysis tool behavior I will describe here.

As in my previous question, “OK” means that the static analysis tool did not warn about an implicit type conversion, and “NOT OK” means that it did.

int main(void)
{
    unsigned int  ui;
    int i;

    ui = (256U); // NOT OK (*) (1)
    i = (256U); // NOT OK (*)  (2)

    i = 256; // OK
    i = 256U; // NOT OK
    ui = 256U; // OK   (3)
    ui = 256; // NOT OK

 return(0);
}

I can understand them all except the first two – what do the parentheses do? If they do nothing in the way of implicit typecasting, then I would expect (1) to be OK and (2) to be NOT OK. If they do automatic type promotion of types smaller than int up to int, then I would expect (1) to be NOT OK and (2) to be OK. But this tool says that both are NOT OK.

Is this a static analysis tool error, or is the tool correct and there’s something else I need to learn about implicit type conversions in C?

(BTW I hope that the value 256 is small enough not be causing overflow on my machine …)

  • 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-25T16:42:28+00:00Added an answer on May 25, 2026 at 4:42 pm

    First, let’s clear up some terminology. Nothing can cause an “implicit cast”, because there is no such thing. A cast is a explicit operator, consisting of a type name in parentheses preceding an expression, such as (double)42; it specifies a conversion. Conversions can be either explicit (specified by a cast operator) or implicit, as in double x = 42;. So what you’re really asking is whether parentheses can cause an implicit conversion.

    And the answer, at least in the code you’ve shown us, is no.

    Quoting the C99 standard (3.7 MB PDF), section 6.5.1p5:

    A parenthesized expression is a primary expression. Its type and value
    are identical to those of the unparenthesized expression. It is an
    lvalue, a function designator, or a void expression if the
    unparenthesized expression is, respectively, an lvalue, a function
    designator, or a void expression.

    And since 256U is already a primary expression, the parentheses make no difference at all; parentheses generally indicate precedence, but in this case there is no predecence to indicate.

    What static analysis tool are you using? You should probably submit a bug report.

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

Sidebar

Related Questions

How do I kill the last spawned background task in Linux? Example: doSomething doAnotherThing
I come from a Java background and have been using C# for the last
I come from more of a Java background. In the last year or two,
Background: Some time ago, I built a system for recording and categorizing application crashes
Last time I had to deal with Java was 2005 and I forgot almost
I haven't used a png hack for IE6 for ages. Last time I used
Is there a way to embed the last command's elapsed wall time in a
I asked a question about C-type sizes which I get a pretty good answer
How can my app get a valid last time connected to domain timestamp from
Alright this is a follow-up to my last question: JTable: Changing cell background when

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.