Deutsch   English   Français   Italiano  
<vm0hjo$15tiu$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!fu-berlin.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.arch
Subject: Re: Calling conventions (particularly 32-bit ARM)
Date: Sun, 12 Jan 2025 14:55:04 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <vm0hjo$15tiu$1@dont-email.me>
References: <vlgngv$1ks4a$1@dont-email.me>
 <4903307dfcce354508c9fc016a4c1ea1@www.novabbs.org>
 <jwv34htql17.fsf-monnier+comp.arch@gnu.org>
 <2025Jan8.230846@mips.complang.tuwien.ac.at>
 <jwvr05cq4tx.fsf-monnier+comp.arch@gnu.org>
 <2025Jan9.082357@mips.complang.tuwien.ac.at> <vlrm00$5nlr$1@dont-email.me>
 <rPdgP.924316$bYV2.501449@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 12 Jan 2025 14:55:06 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c2e27b453553c0792e40b3161bdadf86";
	logging-data="1242718"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/UrXFrc/y3ms3U0pGI+BBDHSTVU5RHN5A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:A5zvlX8zbcLoRlDZXucibrX6+IQ=
In-Reply-To: <rPdgP.924316$bYV2.501449@fx17.iad>
Content-Language: en-GB
Bytes: 3332

On 10/01/2025 19:39, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 09/01/2025 08:23, Anton Ertl wrote:
>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> [Someone wrote:]
>>>>> ABI calling conventions tend to be designed to support at least C,
>>>>> including varargs and often also tolerant of differences between the
>>>>> number of arguments in the caller and callee.
>>
>> Why should an ABI be tolerant of such differences?  In C, calling a
>> function with an unexpected number (or type) of arguments has always
>> been undefined behaviour, and always been something that programmers
>> have strived to avoid.  For variadic functions (including old
>> pre-standard functions), the code does not declare the number or types
>> of arguments, but you still have to match up the caller and callee.
> 
> I'm not sure that's completely true.   Consider, for example,
> main().  It's sort of variadic, but most applications only declare
> the standard C argc/argv arguments.  POSIX systems supply
> a third parameter (envp) and most unix/linux implementations
> supply a fourth parameter (auxv).
> 
> I should think so long as the caller provides at least enough
> parameters to match the callee, there shouldn't be any
> issues.

main() is a special case in C and C++ - it seems fine to say that it 
takes a particular implementation-defined set of parameters no matter 
how it is declared.  If it is defined with fewer parameters than the 
implementation supports, then the definition should be treated as though 
those parameters were included but not used.

> 
>> Call printf() with a mismatch between the format string and the
>> arguments, and you can expect nasal daemons.
> 
> Not if you provide _more_ parameters than the format string
> requires, which can happen with e.g. i18n error message strings.
> 

I've always thought printf was a very unsafe design concept - that usage 
does not help!