[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unwarranted old-style cast warning and non-critical error
From: |
Daniel J Sebald |
Subject: |
Unwarranted old-style cast warning and non-critical error |
Date: |
Fri, 17 Aug 2012 03:24:36 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
When building Octave, gcc issues this old-style cast warning:
In file included from builtins.cc:9:0:
../../octave/src/interpfcn/variables.h:105:40: warning: use of old-style
cast
../../octave/src/interpfcn/variables.h:105:65: warning: use of old-style
cast
It is due to the following line of code, and in particular the DBL_MIN
and DBL_MAX:
extern OCTINTERP_API octave_value
set_internal_variable (double& var, const octave_value_list& args,
int nargout, const char *nm,
double minval = DBL_MIN, double maxval = DBL_MAX);
I think this may be a gcc compiler oversight. I read somewhere that the
warning went away with gcc version 4.5.0-5, but I have version 4.5.1
(from late 2010) and I'm still getting the warning.
I tried to get rid of the warning with "static_cast<double>(DBL_MIN)"
but that did not help.
Can someone please confirm this warning disappeared somewhere along the
way in the last year and a half?
...
This leads to a question. Is the line above intended instead to be the
following (i.e., replace DBL_MIN with -DBL_MAX)?
extern OCTINTERP_API octave_value
set_internal_variable (double& var, const octave_value_list& args,
int nargout, const char *nm,
double minval = -DBL_MAX, double maxval = DBL_MAX);
I'm assuming that the default definitions are meant to be that there is
no restriction on the value, as with the integer case defined before the
double case:
extern OCTINTERP_API octave_value
set_internal_variable (int& var, const octave_value_list& args,
int nargout, const char *nm,
int minval = INT_MIN, int maxval = INT_MAX);
However, INT_MIN and DBL_MIN are not analogous. DBL_MIN is the smallest
positive double value (i.e., greater than zero). I printed out the value:
DBL_MIN = 2.22507e-308
If the minval is meant to be -DBL_MAX, apparently this doesn't make a
difference in behavior, otherwise a bug would have shown up long ago.
Dan
- Unwarranted old-style cast warning and non-critical error,
Daniel J Sebald <=
- Unwarranted old-style cast warning and non-critical error, John W. Eaton, 2012/08/22
- Re: Unwarranted old-style cast warning and non-critical error, Daniel J Sebald, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, John W. Eaton, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, Daniel J Sebald, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, John W. Eaton, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, John W. Eaton, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, Daniel J Sebald, 2012/08/23
- Re: Unwarranted old-style cast warning and non-critical error, Daniel J Sebald, 2012/08/24