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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:46:09+00:00 2026-06-04T04:46:09+00:00

I’ve a theoretical question about these two statements: Assuming p a pointer to an

  • 0

I’ve a theoretical question about these two statements:

Assuming p a pointer to an Integer and a an Integer:

a) if(p==a){.....} or if(p>a)..

b) p=a;

All of them are illegal and b is especially dangerous but how does standard C consider them?

Reading the standard, I haven’t found if they are errors, undefined behaviors, unspecified behavior, constraint violation, if one of them is legal or other.

Looking in the countless similar question, I haven’t found a solution.

  • 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-06-04T04:46:10+00:00Added an answer on June 4, 2026 at 4:46 am

    C11 (n1570) §6.5.8 [Relational operators] / 2:

    Constraints

    One of the following shall hold:

    • both operands have real type; or
    • both operands are pointers to qualified or unqualified versions of compatible object
      types.

    (real type means the integer types, enums, real floating point types and char (§6.2.5/17))

    §6.5.9 [Equality operators]

    Constraints

    One of the following shall hold:

    • both operands have arithmetic type;
    • both operands are pointers to qualified or unqualified versions of compatible types;
    • one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of void; or
    • one operand is a pointer and the other is a null pointer constant.

    §6.5.16.1 [Simple assignment] / 1:

    Constraints

    One of the following shall hold:

    • the left operand has atomic, qualified, or unqualified arithmetic type, and the righ has arithmetic type;
    • the left operand has an atomic, qualified, or unqualified version of a structure or union type compatible with the type of the right;
    • the left operand has atomic, qualified, or unqualified pointer type, and (considering
      the type the left operand would have after lvalue conversion) both operands are
      pointers to qualified or unqualified versions of compatible types, and the type pointed
      to by the left has all the qualifiers of the type pointed to by the right;
    • the left operand has atomic, qualified, or unqualified pointer type, and (considering
      the type the left operand would have after lvalue conversion) one operand is a pointer
      to an object type, and the other is a pointer to a qualified or unqualified version of
      void, and the type pointed to by the left has all the qualifiers of the type pointed to
      by the right;
    • the left operand is an atomic, qualified, or unqualified pointer, and the right is a null
      pointer constant; or
      the left operand has type atomic, qualified, or unqualified _Bool, and the right is a
      pointer.

    Basically, all 3 expressions violated the constraints set in the expression.


    What does violating constraints mean? Errors? But nowhere says that violation of constraints shall cause the translation to fail. The C standard doesn’t seem to be very clear, but the closest interpretation would be:

    §4 [Conformance] / 2:

    If a “shall” or “shall not” requirement that appears outside of a constraint or runtime-constraint is violated, the behavior is undefined.

    but this talks about outside of constraints; and §5.1.1.3 [Diagnostics] / 1:

    A conforming implementation shall produce at least one diagnostic message (identified in
    an implementation-defined manner) if a preprocessing translation unit or translation unit
    contains a violation of any syntax rule or constraint, even if the behavior is also explicitly specified as undefined or implementation-defined. Diagnostic messages need not be produced in other circumstances.

    so the compiler needs to at least produce a message (as we can see in gcc), but did not say what they should do after that.

    The example after this paragraph mentions that

    EXAMPLE

    An implementation shall issue a diagnostic for the translation unit:

       char i;
       int i;
    

    because in those cases where wording in this International Standard describes the behavior for a construct as being both a constraint error and resulting in undefined behavior, the constraint error shall be diagnosed.

    and §6.7 [Declarations] / 3 does not explicitly mention that violating the Constraint will cause undefined behavior.

    Therefore, I deduce that your 3 expressions are all undefined behaviors, accompanied with diagnostic messages.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.