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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:45:11+00:00 2026-05-25T20:45:11+00:00

const QPointF points[] = { QPointF(r.left() – i, r.top() – i), QPointF(r.right() + i,

  • 0
const QPointF points[] =
{
    QPointF(r.left() - i, r.top() - i),
    QPointF(r.right() + i, r.top() - i),
    QPointF(r.right() + i, r.bottom() + i),
    QPointF(r.left() - i, r.bottom() + i),
    points[0] // is this line valid (according to the C++ standard)?
};

While this compiles with the MS Visual Studio Compiler, i am not sure if this is valid code according to the C++ Standard.

Quotes from the Standard would be highly appreciated.

  • 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-25T20:45:11+00:00Added an answer on May 25, 2026 at 8:45 pm

    C++03/C++11 answer


    No, it’s not.

    On the right-hand side of the =, points does exist1 but the initialiser is only applied after all its operands have been evaluated.

    • If points is at namespace scope (and thus has static storage duration and has been zero-initialized2), then this is “safe” but your use of points[0] there is going to give you 0, rather than QPointF(r.left() - i, r.top() - i) again.

    • If points has automatic storage duration — it has not yet been initialised so your use of points[0] is attempting to use an uninitialised variable, where points[0] has an indeterminate value… which is bad3.

    It’s difficult to provide standard references for this, other than to say that there is nothing in 8.5 "Initializers" that explicitly makes this possible, and rules elsewhere fill in the rest.


    1 [n3290: 3.3.2/1]: The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any), except as noted below. [ Example:

    int x = 12;
    { int x = x; }
    

    Here the second x is initialized with its own (indeterminate) value. —end example ]

    2 [n3290: 3.6.2/2]: Variables with static storage duration (3.7.1) or thread storage duration (3.7.2) shall be zero-initialized (8.5)
    before any other initialization takes place. [..]

    3 [n3290: 17.6.3.3/2]: [..] [ Note: Operations
    involving indeterminate values may cause undefined behavior. —end note ]

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

Sidebar

Related Questions

int main() { const int maxint=100;//The program will crash if this line is put
const static int foo = 42; I saw this in some code here on
I have the following constructor of an object Segment::Segment(QPointF const& start, QPointF const& end):
const int t=5; char buf[t+5]; When I compile this gives error in C but
const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]); CGContextSetFillColor(context, color); I have black background. While
const unsigned int omode = cimg::exception_mode(); cimg::exception_mode() = 0; Never see this kinda syntax
The const modifier in C++ before star means that using this pointer the value
1) const int[] array={1,2,3,4}; //this gives below error Error 1 'ConsoleApplication1.Main.array' is of type
In this declaration data Const a = Const Integer Haskell infers that Const is
const char* title = old title; HWND hwnd = FindWindow(title, title); SetWindowText(hwnd, new title);

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.