mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-11-16 13:09:16 +00:00
Make va_arg(ap,double) work correctly.
This was not working because floating-point arguments are really passed in the extended format, but based on the wording in the C standard a type of "double" should still work for arguments passed with that type. This fixes #29. (The bug report was valid only with respect to double, not float or long double.)
This commit is contained in:
parent
92f1344a6e
commit
438942692a
@ -27,7 +27,9 @@ typedef char *__va_list[2];
|
|||||||
typedef __va_list va_list;
|
typedef __va_list va_list;
|
||||||
#define va_end(a) __va_end(a)
|
#define va_end(a) __va_end(a)
|
||||||
#define va_start(ap,LastFixedParm) ((void) ((ap)[0] = (ap)[1] = (char *) (&LastFixedParm + 1)))
|
#define va_start(ap,LastFixedParm) ((void) ((ap)[0] = (ap)[1] = (char *) (&LastFixedParm + 1)))
|
||||||
#define va_arg(ap,type) ((type *)((ap)[0] += sizeof(type)))[-1]
|
#define va_arg(ap,type) _Generic(*(type *)0, \
|
||||||
|
double: (type)((long double *)((ap)[0] += sizeof(long double)))[-1], \
|
||||||
|
default: ((type *)((ap)[0] += sizeof(type)))[-1])
|
||||||
|
|
||||||
void __va_end(va_list);
|
void __va_end(va_list);
|
||||||
|
|
||||||
|
4
cc.notes
4
cc.notes
@ -1215,6 +1215,10 @@ int foo(int[42]);
|
|||||||
|
|
||||||
162. In certain cases, an assignment from a location with an 8-bit type to a location with a 16-bit type might store the wrong value.
|
162. In certain cases, an assignment from a location with an 8-bit type to a location with a 16-bit type might store the wrong value.
|
||||||
|
|
||||||
|
163. When an argument of type double was passed to a function taking variable arguments, va_arg(ap,double) would not retrieve it correctly.
|
||||||
|
|
||||||
|
(Devin Reade)
|
||||||
|
|
||||||
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
|
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
|
||||||
|
|
||||||
1. In some situations, fread() reread the first 1K or so of the file.
|
1. In some situations, fread() reread the first 1K or so of the file.
|
||||||
|
Loading…
Reference in New Issue
Block a user