[FFmpeg-devel] [PATCH] libavcodec/wmavoice.c: local variablepow might mask pow function

Eli Friedman eli.friedman
Mon Jul 26 11:17:57 CEST 2010


On Mon, Jul 26, 2010 at 1:27 AM, Axel Holzinger <aholzinger at gmx.de> wrote:
> Hi Eli et al,
>
> On Sun, Jul 25, 2010 at 9:41 PM, Eli Friedman wrote:
>> On Sun, Jul 25, 2010 at 12:18 PM, Axel Holzinger
>> <aholzinger at gmx.de> wrote:
>> > The issue is that a local variable pow masks a function pow
>> > and that hurts if powf - which is used in the scope of local
>> > variable pow - is not a function but a macro using double
>> > precision pow function.
>>
>> And I'm pointing out that such an implementation is not
>> correct per C99.
>
> I read the standard and under 7.1.4 (1) it's stated that standard
> headers may export function like macros. I don't see how this couldn't
> be correct C99. Could you please provide a reference where it's stated
> that a function like macro is forbidden in a standard header (at least
> for powf)?

It's okay for powf to be a macro.

> Also Unix/Posix allows powf to be implemented as a macro:
> http://www.opengroup.org/onlinepubs/009695399/basedefs/math.h.html
>
>> > Besides taking the effort to apply and document a patch,
>> > what do you think stands against the patch?
>>
>> Simply that you haven't actually pointed to why this is
>> necessary other than the abstract possibility of a
>> non-conforming implementation of math.h.
>
> As mentioned above, I can't see why such an implementation would be
> non-conforming. Can you elaborate.

Per C99, 7.1.3p1 and p2, "pow" is only reserved for use as a macro
name or a file-scope identifier.  Therefore, it's legal to use it as
the name of a local variable in any context.  A specific case of this
is that the construct in wmavoice.c is legal C99 code, and is required
to compile on any conforming C99 implementation.

-Eli



More information about the ffmpeg-devel mailing list