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

  • Home
  • SEARCH
  • 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 881063
In Process

The Archive Base Latest Questions

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

Consider the following code: template<bool> class StaticAssert; template<> class StaticAssert<true> {}; StaticAssert< (-1 <

  • 0

Consider the following code:

template<bool> class StaticAssert;
template<> class StaticAssert<true> {};
StaticAssert< (-1 < sizeof(int)) > xyz1; // Compile error
StaticAssert< (-1 > sizeof(int)) > xyz2; // OK

Why is -1 > sizeof(int) true?

  1. Is it true that -1 is promoted to unsigned(-1) and then unsigned(-1) > sizeof(int).
  2. Is it true that -1 > sizeof(int) is equivalent to -1 > size_t(4) if sizeof(int) is 4. If this is so why -1 > size_t(4) is false?

Is this C++ standard comformant?

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

    The following is how standard (ISO 14882) explains abort -1 > sizeof(int)

    Relational operator `>’ is defined in 5.9 (expr.rel/2)

    The usual arithmetic conversions are
    performed on operands of arithmetic or
    enumeration type. …

    The usual arithmetic conversions is defined in 5 (expr/9)

    … The pattern is called the usual arithmetic conversions, which are defined as following:

    • If either operand is of type long
      double, …
    • Otherwise, if either operand is dobule, …
    • Otherwise, if either operand is float, …
    • Otherwise, the integral promotions shall be performed on both operands.
    • …

    The integral promotions is defined in 4.5 (conv.prom/1)

    An rvalue of type char, signed char,
    unsigned char, short int, or unsigned
    short int can be converted to an
    rvalue of type int if int can
    represent all the values of the source
    type; otherwise, the source rvalue can
    be converted to an rvalue of type
    unsigned int.

    The result of sizeof is defined in 5.3.3 (expr.sizeof/6)

    The result is a constant of type
    size_t

    size_t is defined in C standard (ISO 9899), which is unsigned integer type.

    So for -1 > sizeof(int), the > triggers usual arithmetic conversions. The usual arithmetic conversion converts -1 to unsigned int because int cannot represent all the value of size_t. -1 becomes a very large number depend on platform. So -1 > sizeof(int) is true.

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

Sidebar

Ask A Question

Stats

  • Questions 479k
  • Answers 479k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make sure the autoloadernamespace is properly configured in your application.ini.… May 16, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer Yes, you can control GDB from Python. The Python documentation… May 16, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer One elegant way is to use an array and implode().… May 16, 2026 at 5:51 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.