Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Suzuki__Hajime
Beginner
118 Views

[bug report] Variable length array in statement expression

Hi,

I encountered a phenomenon that a statement expression is always evaluated as zero when variable length array is declared inside it. Constant-length array did not cause this problem, including an array whose length is specified by a variable which is qualified as `const`. It reproduced with Intel C Compiler version 13.0.1, 16.0.3, 17.0.0, and 18.0.0 (which were available at https://godbolt.org/ and my environment). It didn't happen with the C++ compiler (icpc). The following is a code that reproduces the situation. Here is a link to the same code at compiler explorer: https://godbolt.org/g/YrNgfb .

#include <stddef.h>
int vla_in_statement_expression(void)
{
    size_t len = 5;
    int a = ({ int vla[len]; 42; });
    return(a);
}

I would appreciate if the compiler team respond to this problem. I'm sorry if it is not a bug but a correct behavior that is described in the document.

Thanks,

Hajime Suzuki

 

0 Kudos
4 Replies
Viet_H_Intel
Moderator
118 Views

 

Thanks for reporting this issue. Let me look into it and get back to you.

Regards,

Viet 

Viet_H_Intel
Moderator
118 Views

 

I've filed a bug report to our developer. The internal tracking is: CMPLRS-50845. I'll let you know when we have a fix.

Thanks,

Viet

Suzuki__Hajime
Beginner
118 Views

Thanks! I really appreciate your quick response.

Hajime

Bekes__Gabor
Beginner
118 Views

Hello,

the reference (version 19 at least) says that 'Variable-length arrays are no longer allowed in statement expressions.'

Reply