[Asterisk-Dev] Re: asterisk/include/asterisk utils.h,1.46,1.47
Luigi Rizzo
rizzo at icir.org
Sun Oct 30 10:58:48 MST 2005
On Sun, Oct 30, 2005 at 12:40:32PM -0600, Kevin P. Fleming wrote:
> Luigi Rizzo wrote:
>
> > i am saying a different thing. If you pass an argument by value,
> > almost always the compiler passes it as a native integer type,
> > because of alignment issues of surrounding arguments.
> > This in turn results in an implicit cast (which you cannot avoid),
> > which is often flagged by -Wimplicit-cast and this prevents from
> > running with -Werror.
>
> OK, I understand your point now.
>
> However, in this case since the range of the argument is explicitly the
> size of a 'short' and users of the API call should be made fully aware
> of that, I'm hesitant to some other argument type.
understood. I am just pointing out the issue.
> I'm a little confused why an internal compiler optimization
> (platform-based) would cause an 'implicit cast' as defined by this
> warning option... I would think that option to be intended to find cases
> where the programmer accidentally neglected to explicitly cast a value
> (or use the proper variable types).
you can call it a broken compiler (in case, gcc 2.95 i think),
but my goal is not to point fingers but just write robust and portable code,
and to this end i prefer to run the compiler as pedantic as possible.
In the meantime i found some of my notes where i recorded this type
of problem and here it is:
# We cannot include Wconversion due to compiler's brokennes when
# dealing with mode_t arguments e.g. in mkdir(), umask() etc.
# WARNINGS += -Wconversion # broken on some platforms
the option is -Wconversion not -Wimplicit-cast as i erroneously said.
The operand triggering the bug was of type mode_t, defined as
typedef u_int16_t mode_t
and one of the offending compilers is gcc 2.95.
Just for the records.
cheers
luigi
More information about the asterisk-dev
mailing list