this program does SIGSEGV on my qnx 6.2.1 NC.
it’s my hands or it is really a bug?
Yours, I’m afraid. Section 7.8.1.1 (1989 version) of the standard says:
If the parameter “parmN” is declared with the register storage class, with
a function or array type, or with a type that is not compatable with the
type that results after the application of the default argument promotion
rules, the behaviour is undefined.
“parmN” is the parm passed to va_start(). Since the default argument
promotion rules appied to “short” gives “int”, and “short” is not compatable
with “int”, the behaviour is undefined. If you change the type of “num1”
to an “int”, it works as intended.
If the parameter “parmN” is declared with the register storage class, with
a function or array type, or with a type that is not compatable with the
type that results after the application of the default argument promotion
rules, the behaviour is undefined.
“parmN” is the parm passed to va_start(). Since the default argument
promotion rules appied to “short” gives “int”, and “short” is not compatable
with “int”, the behaviour is undefined. If you change the type of “num1”
to an “int”, it works as intended.
Oh, i see…
But now, we have another piece of software running under QNX! The
Ur-Quan Masters, sc2.sf.net…
If the parameter “parmN” is declared with the register storage class, with
a function or array type, or with a type that is not compatable with the
type that results after the application of the default argument promotion
rules, the behaviour is undefined.
“parmN” is the parm passed to va_start(). Since the default argument
promotion rules appied to “short” gives “int”, and “short” is not compatable
with “int”, the behaviour is undefined. If you change the type of “num1”
to an “int”, it works as intended.
Oh, i see…
But now, we have another piece of software running under QNX! The
Ur-Quan Masters, sc2.sf.net…
Cool. I actually helped someone else track this same bug down on irc
one night. Seems that GNU’s libc’s behavior is defined to “work regardless”.
So there is a decent amount of code written on Linux that doesn’t have any
issues until you build it on QNX.
chris
–
Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll – http://qnx.wox.org/