Liste des Groupes | Revenir à c arch |
Stefan Monnier <monnier@iro.umontreal.ca> writes: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. Call printf() with a mismatch between the format string and the arguments, and you can expect nasal daemons.
[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.
I would, yes. The efficiency of good code should not suffer because of the existence of bad code.>You are head of a group of people who design a new architecture (say,
I can agree that it's important to support those use-cases (varargs
obviously, mismatched arg numbers less so),
it's 2010 and you design ARM A64, or it's 2014 and you design RISC-V).
Your ABI designer comes to you and tells you that his life would be
easier if it was ok that programs with mismatched arguments don't need
to work. Would you tell him that they don't need to work?
If yes, a few years down the road your prospective customers have toHow many people actually want to use code where some functions are called with an incorrect number of parameters? Such code is /broken/. If it ever gave results that the original users were happy with, it is by luck - no matter what ABI you have for your new architecture and new tools, it's pure luck whether things work or not in any sense.
decide whether to go for your newfangled architecture or one of the
established ones. They learn that a number of programs work
everywhere else, but not on your architecture. How many of them will
be placated by your reasoning that these programs are not strictly
confoming standard programs? How many will be alarmed by your
admission that you find it ok that you find it ok that such programs
don't work on your architecture? After all, hardly any program is a
strictly conforming standard program.
My original post was about an ABI for microcontroller programming. For that use, my answer is a definite "yes".only sloppy ancient C callsYou find it ok to design a calling convention such that ancient C
functions without proper declarations)
programs do not work?
What benefit do you expect from such a calling convention? To allowThat sounds like a benefit to me.
to use registers as arguments (and not callee-saved) that would
otherwise be preferably used as callee-saved registers?
I would certainly be OK with that. I can understand that some people will disagree, but I really think there are better ways to handle old and/or broken code.even if it comes at the cost ofThat would mean that you find it ok that existing programs that use
using different calling conventions for the two cases.
vararg functions like printf but do not declare them before use don't
work on your newfangled architecture.
Les messages affichés proviennent d'usenet.