gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] kf in mos1 model


From: al davis
Subject: Re: [Gnucap-devel] kf in mos1 model
Date: Mon, 12 May 2014 21:57:49 -0400
User-agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; )

On Friday 09 May 2014, Felix Salfelder wrote:
> apparently, something causes kf and af to misbehave. which
> compilers did you use?

g++ 2.7.2 recently ..

I think I found the problem.

There are really two problems, the one you noticed and one that 
I found while investigating.

I recall noticing it a while back but there was so much else to 
do that I put it off.

The problem has to do with construction order for what I thought 
was constants.  Apparently g++ treats const (as in constant.h) 
as static objects that need to be constructed, and in this case 
the static instance of MODEL_BUILT_IN_MOS1 happened to get 
constructed before the constant MAXDBL, so NOT_INPUT was zero.

Problem solved by using #define instead.


//#ifdef HAS_NUMERIC_LIMITS
//double const MAXDBL    = std::numeric_limits<double>::max();
//#else
//double const MAXDBL    = DBL_MAX;
//#endif

#define MAXDBL (DBL_MAX)

Now I question all usage of "const" in constant.h .
Should they all revert to #define ?????

In this case, following lines could change to DBL_MAX to 
simplify, but according to C++ docs std::numeric_limits is the 
"preferred" way to do it.


The other issue that surfaced has to do with modelgen, 
particularly code generation when there is inheritance.  When 
the hide_base option is used, parameters in the base that are 
hidden and re-exposed are not properly initialized.  It appears 
to be ok when the value is a number or defaulted, but parameter 
expressions are not properly evaluated.  Missing code in 
precalc_first.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]