P
pemo
I've just been trying out the Watcom compiler from
http://www.openwatcom.org, and almost immediately compiled some working
source that errored.
The code is
char buffer[1000];
...
if(opt & out_std)
{
fputs(&buffer, stdout);
}
Note that &buffer should [ideally] have been either &buffer[0] or just plain
buffer.
However, the same code compiles cleanly using gcc (ecven when
using -pedantic), icl, and MS's cl compilers.
In the c99 std it has the following:
6.5.3.2 Address and indirection operators
Constraints
1 The operand of the unary & operator shall be either a function designator,
the result of a
[] or unary * operator, or an lvalue that designates an object that is not a
bit-field and is
not declared with the register storage-class specifier.
I'm interpreting the beginning of this as saying that the follow are valid:
char array[1];
int n;
int * p;
&array[0];
&n;
&*p;
However, I can't find anything that says that [say] puts(&buffer) is valid.
So, any comments?
http://www.openwatcom.org, and almost immediately compiled some working
source that errored.
The code is
char buffer[1000];
...
if(opt & out_std)
{
fputs(&buffer, stdout);
}
Note that &buffer should [ideally] have been either &buffer[0] or just plain
buffer.
However, the same code compiles cleanly using gcc (ecven when
using -pedantic), icl, and MS's cl compilers.
In the c99 std it has the following:
6.5.3.2 Address and indirection operators
Constraints
1 The operand of the unary & operator shall be either a function designator,
the result of a
[] or unary * operator, or an lvalue that designates an object that is not a
bit-field and is
not declared with the register storage-class specifier.
I'm interpreting the beginning of this as saying that the follow are valid:
char array[1];
int n;
int * p;
&array[0];
&n;
&*p;
However, I can't find anything that says that [say] puts(&buffer) is valid.
So, any comments?