[cfe-dev] can foo() be called with arguments?
edwintorok at gmail.com
Sun Feb 17 13:45:00 PST 2008
Chris Lattner wrote:
> On Feb 17, 2008, at 11:17 AM, Eli Friedman wrote:
>> On Feb 17, 2008 10:30 AM, Török Edwin <edwin at clamav.net> wrote:
>>> From my reading of the C99 standard (N1256.pdf) calling foo with
>>> parameters when it is declared as foo() is allowed only if the
>>> declaration doesn't involve a definition too.
>>> If it involves a definition, then you can't call it with parameters,
>>> and foo() is equivalent to foo(void). Is this correct?
>> See http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_317.htm.
>> Essentially, executing the call is technically undefined behavior, but
>> it's a perfectly legal construct. I've filed
>> http://llvm.org/bugs/show_bug.cgi?id=2042 on the issue.
>> It looks like your module does actually execute such an undefined
>> call, so the program technically has undefined behavior.
Thanks for the pointer.
>> That said,
>> I've never heard of a C compiler producing code that actually did
>> anything weird... generally, C calling conventions allow for an
>> arbitrary number of arguments even if the callee doesn't expect them
>> for compatibility reasons.
I've filed a bug for the original program to avoid the undefined behaviour.
> I just checked in a fix for this,
Thanks a lot!
More information about the cfe-dev