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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:24:31+00:00 2026-06-05T06:24:31+00:00

struct E_Point { double x, y; E_Point(): x(0), y(0) {} E_Point(double x, double y)

  • 0
struct E_Point {
  double x, y;
  E_Point(): x(0), y(0) {}
  E_Point(double x, double y) : x(x), y(y) {}
};

E_Point problem[] = { 
  {0.3871953044519425, -0.91857980824611341}, // Error: initialization of non-aggregate type 'E_Point' with an initializer list
  {0.36139704793723609, 0.91605957361605106}, 
  {-0.8208980020500205, 0.52853407296583088}, 
  {0.36178501611208552, 0.88880385168617226}, 
  {-0.43211245441046209, 0.6803420222771047} 
};

Compiling with clang 3.1.

I should point out that this compiles on GCC 4.6.1.

My current understanding is that problem is a non-aggregate type because it is an array of structs, making it compound and not just simply either a struct or array.

But sending the -std=c++11 flag to clang does not alleviate the problem.

Update: Okay. Looks like my version of clang is somehow flawed and can’t handle this for whatever reason.

What’s a more traditional way to init? Do I do it this way? This compiles, but does it produce the same code? Will it call the ctor while the original doesn’t?

E_Point problem[] = {
    E_Point(0.3871953044519425, -0.91857980824611341), // 1559
    E_Point(0.36139704793723609, 0.91605957361605106), // 1560
    E_Point(-0.8208980020500205, 0.52853407296583088), // 1798
    E_Point(0.36178501611208552, 0.88880385168617226), // 1799
    E_Point(-0.43211245441046209, 0.6803420222771047) // 1800
};
  • 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-05T06:24:33+00:00Added an answer on June 5, 2026 at 6:24 am

    That is a bug in clang++:

    http://llvm.org/bugs/show_bug.cgi?id=12670

    In your case you can just use the explicit call to the constructor, as you provide in the last code snippet. As of whether the semantics are really the same (will it generate the same code), in most cases it will.

    The case where the different syntax will lead to different behavior is when the type being constructed has a constructor that takes a std::initializer_list<>, in which case the brace-initializer will construct that initializer list. If the type does not have such a constructor, as is your case, the brace-initializer will call the appropriate constructor.

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

Sidebar

Related Questions

I have a std::vector that holds a Point struct (x,y,z and some other non-pointer
I am having a problem with my linked list. I'm pretty sure it is
I want to access a C function that returns a struct containing double arrays
I have: struct DoubleVec { std::vector<double> data; }; DoubleVec operator+(const DoubleVec& lhs, const DoubleVec&
I've a weird problem with malloc. I have this typedefs: typedef struct buffer {
I have something like this in my code typedef struct ts_fem_mesh { double **vertices;
typedef pair<double, double> dd; const double epsilon = 1e-6; struct sort_by_polar_angle { dd center;
C++ typedef struct someStruct { int val1, val2; double val3; } someStruct; someStruct a
I have a std::set which is of type point struct point { int x;
In Racket this gives me an error: (struct point-in-plane (pos_x pos_y)) (struct pixel point-in-plane

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.