Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Warning for uninitialized variable in chained constructor
Warning for uninitialized variable in chained constructor [message #1767389] Wed, 05 July 2017 09:55 Go to next message
Eclipse UserFriend
I have a template class with a chained constructor. The child constructor get a CDT warning that it does not initialize all of the variables even though they are initialized in the parent constructor. I have tried putting the comment @suppress("Class members should be properly initialized") pretty much everywhere I can think of to get it to work, but it never seems to be recognized. Trying to make sure I am not doing something wrong before posting tickets to bugzilla.

example code:

GenericDescriptor(PsiReader &psiReader, bool shouldReadFullDescriptor = true)
{
... // initializes variables and sets up class.
}

GenericDescriptor(PsiReader &psiReader,
T expectedType)
:GenericDescriptor(psiReader, false)
{
... //performs additional checks and set up
}

To me it seems like there are two things wrong here. First adding the @suppress comment after the line with the constructor should cause the warning to be suppressed and second the warning should never be generated since the variables are being initialized in the chained constructor.

for the record looks like the @suppress comment tag was added via https://bugs.eclipse.org/bugs/show_bug.cgi?id=383576

[Updated on: Wed, 05 July 2017 09:59] by Moderator

Re: Warning for uninitialized variable in chained constructor [message #1767449 is a reply to message #1767389] Thu, 06 July 2017 04:21 Go to previous messageGo to next message
Eclipse UserFriend
Two parts to the answer:

1) The incorrect warning is probably a bug, so go ahead and file it.

2) In the meantime, you will probably want @suppress to work. It should be on the same line as the warning marker is.

However, for either case most likely a minimal reproducible test case is needed. Can you provide one? If so, I can pursue further both those options.

Thanks,
Jonah
Re: Warning for uninitialized variable in chained constructor [message #1767495 is a reply to message #1767449] Thu, 06 July 2017 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jonah,
Thanks for the reply.

1) I created ticket https://bugs.eclipse.org/bugs/show_bug.cgi?id=519311 about the initialization problem.

2) I got the warning suppression to finally work. My constructor signature spans more than one line. It never occurred to me to put the comment in the middle of the signature on the first line. I put it at the end of the signature, after the call to the other constructor, and after the whole constructor. Your comment got me to try putting it on the line the constructor started on, and that causes it to work. So I guess that works as intended, so that probably does not warrant a ticket.

thanks again for you help
Matthew
Re: Warning for uninitialized variable in chained constructor [message #1767497 is a reply to message #1767495] Thu, 06 July 2017 09:18 Go to previous message
Eclipse UserFriend
Glad to hear you have a short term solution, and thanks for submitting a minimum example with the bug report.
Previous Topic:How I get STL-funktionalities in Arduino-Sloeber ?
Next Topic:Using my ISP Programmer from the Arduino plugin?
Goto Forum:
  


Current Time: Wed Mar 19 01:26:38 EDT 2025

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

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

Back to the top