This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 01/24/2018 11:46 AM, Andre Vieira (lists) wrote:
The final draft of the C11 standard, which I assume was not changed in the final release, does say that only the chosen expression is evaluated. (Which is as it must be. If it is choosing function names, for example, it can hardly evaluate a non-chosen option, as that means calling the function. The example they give is actually choosing a function.) A cast is an expression, so it appears that you do need to chase it with upstream GCC. It obviously has to parse each selection, but it must only evaluate one.Hi, I looked a bit further into this and I can't reproduce this behavior for the i386 backend. So I had a look through GCC's parser implementation for _Generic and it seems GCC evaluates the expressions in each matching case, that is to say it will also parse the default case. In arm, the type of va_list is a struct, since it is invalid to cast structs to pointers, the c-parser will error out when it parses this cast in the default case. For an i386 gcc, and I'm guessing your case is the same, the type of va_list can be cast to a pointer type, so it parses it without errors. I don't know if parsing the expression of default if another case has matched is intended behavior. I will investigate this further and if I can convince myself this is wrong behavior I'll chase it with upstream gcc.
Craig
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |