Return to Home
  View the contents of your Cart View cart  
  0 item(s) in cart  
  Checkout  

Gimpel Software - Discussion Forum
Discussion Forum
We invite you to use this forum to communicate with other PC-lint and FlexeLint users. You do not need to log in to post a message. WARNING: Your email address will not be encrypted. We recommend that you obfuscate it as protection from web crawlers. To receive technical support directly from Gimpel Software, please follow the guidelines at http://www.gimpel.com/html/support.htm
Gimpel Software - Discussion Forum
Subject From Date & Time
constructors that initialize variables and use initializers? Michael Kelley October 19, 2011
9:32:17 PM
  Re: constructors that initialize variables and use initializers? Michael Kelley November 10, 2011
4:52:21 PM
  Re: constructors that initialize variables and use initializers? Robert Gamble November 16, 2011
2:34:51 PM
          Re: constructors that initialize variables and use initializers? Alexander November 17, 2011
11:56:21 AM
                  Re: constructors that initialize variables and use initializers? Kurt April 06, 2016
5:24:56 PM
 
Subject: constructors that initialize variables and use initializers?
Date: October 19, 2011
9:32:17 PM
Name: Michael Kelley
Email: michael.kelley@navteq.com
Message:
Refer to the code below for this problem.

I have a class that initializes member variables in the constructor and call other functions 
that initialize member variables.  If you specify that a function is an initializer, Lint 
expects that you initialize all member variables in that function (except for consts or 
references) and it'll throw error 1565 for variables that aren't, even if those variables are 
initialized in the constructor.  If I suppress error 1565, then any variable that is not 
initialized in A() or SetVarB() will not be flagged by Lint as being uninitialized.

Is there a way to tell lint to use the constructor and the initializer to check for 
uninitialized variables?
-----------------------------------------------------------------

/* Enter your C++ code here (you can delete this line) */

//lint -sem(A::SetVarB,initializer)
class A
{
public:
  A() : VarA(1) {SetVarB();}

private:
  void SetVarB() {VarB=1;}
  int VarA;
  int VarB;
  int VarC;
};
Reply to this Message! Previous Message Next Message
 
Subject: Re: constructors that initialize variables and use initializers?
Date: November 10, 2011
4:52:21 PM
Name: Michael Kelley
Email: michael.kelley@navteq.com
Message:
Anyone?
Reply to this Message! Previous Message Next Message
 
Subject: Re: constructors that initialize variables and use initializers?
Date: November 16, 2011
2:34:51 PM
Name: Robert Gamble
Message:
I am not aware of any way to accomplish what you
are trying to do without restructuring your code
(to move all of the initializations into the
constructor or the initializer function).
Reply to this Message! Previous Message Next Message
 
Subject: Re: constructors that initialize variables and use initializers?
Date: November 17, 2011
11:56:21 AM
Name: Alexander
Message:
I've also been struggling with this in the past,
and often (not always) came to the conclusion,
that A should be derived from some base class B
holding the other member variables.
Reply to this Message! Previous Message Next Message
 
Subject: Re: constructors that initialize variables and use initializers?
Date: April 06, 2016
5:24:56 PM
Name: Kurt
Email: kfank_at_upwardaccess_dot_see_oh_mm
Message:
A feature request has been posted here:
http://support.gimpel.com/forums/225702-general/suggestions/5507406-having-multiple-initializer-functions-in-a-constru

You can vote for it there.
Reply to this Message! Previous Message Next Message