- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all!
Although this code has many features that are strictly forbidden by the C standard I think most of them are supported as Intel extensions.
#include <stdlib.h>
#include <stdio.h>
#if defined(RANK)
#define IRANK RANK
#else
#define IRANK 0
#endif
#define MSTRUCT(r) struct{int dim
int main(int argc, char **argv){
int n = IRANK;
MSTRUCT(n) s;
printf("%zu, %zu\n", sizeof(s), sizeof(MSTRUCT(n)));
return EXIT_SUCCESS;
}
I would expect the code to print two identical numbers.
Using -ftrapuv changes the value printed, -O0 had the same effect on a more complicated variation.
Thank you very much.
Best regards,
José Rui
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This code has an uninitialized variable "int dim[0];" which can lead to undefined behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I meant is "variable length array" not "uninitialized variable"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the code has several features that are not standard conforming, but I think that some of them are supported by Intel as extensions.
Thank you very much.
Best regards,
José Rui

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page