Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse CDT C++ Aggregate (brace) Initialization fails with newer eclipse Versions(Eclipse CDT C++ Aggregate (brace) Initialization fails with newer eclipse Versions 2019-03 - 2020-06.)
Eclipse CDT C++ Aggregate (brace) Initialization fails with newer eclipse Versions [message #1829278] Tue, 30 June 2020 11:37 Go to next message
Evigenia Power is currently offline Evigenia PowerFriend
Messages: 1
Registered: June 2020
Junior Member
Preconditions:
Existing C++ code works fine with eclipse 2018-12 and compiles error and warning free.

Problem Description:
C++ aggregate (brace) initialization fails with newer eclipse versions 2019-03 - 2020-06.

Examples:
1. String initialization with function return value
std::string getVersStr() // method declaration

std::string tempSrcStr{getVersStr()}; // eclipse complains with 'invalid arguments'

2. Aggregate initialization in class initialization list
...

private:
std::list<Port> portList;

public:
PortMap(const std::list<Port> &_portList) : portList(_portList) // eclipse complains wirh symbol 'portList' could not be resolved

...

For sure using round brackets instead of braces works.
But I don't wan't to change lots of code lines in order just to satisfy eclipse, when code compiles fine and works fine with older eclipse version 2018-12.

I don't understand why such code affecting changes are necessary from one eclipse version to other.

Question:
Is there any possibility to make eclipse accepting such aggreagate initializations?
Re: Eclipse CDT C++ Aggregate (brace) Initialization fails with newer eclipse Versions [message #1836883 is a reply to message #1829278] Sun, 17 January 2021 08:59 Go to previous messageGo to next message
Bart Van Hofwegen is currently offline Bart Van HofwegenFriend
Messages: 2
Registered: January 2021
Junior Member
Same here with 2020-12 (4.18.0), as in example:
struct S {
	int i;
	int j;
};

S sa {1, 2};
S sb {sa};

The last line shows a squiggle with " Invalid arguments ' Candidates are: S() S (const S &) '", while it is perfectly legal code for list initialization, as per the standard:
Quote:
The effects of list initialization of an object of type T are: If T is an aggregate class and the initializer list has a single element of the same or derived type (possibly cv-qualified), the object is initialized from that element (by copy-initialization for copy-list-initialization, or by direct-initialization for direct-list-initialization).


Worse yet, as stated, is the error displayed with a constructor initialization list.

Have you ever found a solution for this? I could not find it listed as a known bug (but that may be because I did not search thoroughly enough).
Re: Eclipse CDT C++ Aggregate (brace) Initialization fails with newer eclipse Versions [message #1836884 is a reply to message #1829278] Sun, 17 January 2021 09:19 Go to previous message
Bart Van Hofwegen is currently offline Bart Van HofwegenFriend
Messages: 2
Registered: January 2021
Junior Member
Edit: It seems to be a know bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=559318
Previous Topic:Setting C++ standard
Next Topic:Having Multiple Startup Files
Goto Forum:
  


Current Time: Thu Oct 03 16:53:59 GMT 2024

Powered by FUDForum. Page generated in 0.03735 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top