This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: no conversion from char[] to char* on function calls under circumstances [was: A bug?]
On Tuesday 2008-12-16 18:43, Michel Van den Bergh wrote:
> Andrew Haley wrote:
>> Andrew Thomas Pinski wrote:
>>
>> > C++98 is not C99 :) there is no rvalue to lvalue conversion for rvalue
>> > arrays in C++98. Also this code is still undefined C99 but will most
>> > likely become valid C1x.
>>
>> Ah, it's an rvalue array. Good point.
>>
> Ok now I understand. I assume this behaviour is not triggered often as in C it
> is
> not so common to have an array which is an rvalue.
Is not this a use of an rvalue array too?:
#include <stdio.h>
int main(void)
{
printf("%p\n", (struct { char x[20]; }){{"Hello"}}.x);
}
This one actually works fine. So maybe it's really limited to
the case where a function returning a struct is involved.