- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does ICC support GCC's __attribute__((cleanup(..)))?
The documentation (http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/cpp/lin/bldaps_cls/common/bldaps_gcc_compat_comm.htm) calims "Specifying Attributes of Variables" is supported.
The following code compiles cleanly with 12.0.5.225. But the "cleanup" doesn't really work.
The 10.1.026 compiler gives out a warning that the attribute is ignored.
slon.c(11): warning #1292: attribute "cleanup" ignored
int __attribute__((cleanup(check_finished))) finished = 0;
Is this a dead-end or am i missing some switch/pragma to enable the support?
#include
#include
void check_finished(int *p) {
if (!*p)
printf("aborted.\\n");
}
int main(int argc, char *argv[]) {
do {
int __attribute__((cleanup(check_finished))) finished = 0;
printf("Begin...");
if (argc > 1 && !strcmp("boo", argv[1]))
break;
printf("end.\\n");
finished = 1;
} while (0);
return 0;
}
The documentation (http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/cpp/lin/bldaps_cls/common/bldaps_gcc_compat_comm.htm) calims "Specifying Attributes of Variables" is supported.
The following code compiles cleanly with 12.0.5.225. But the "cleanup" doesn't really work.
The 10.1.026 compiler gives out a warning that the attribute is ignored.
slon.c(11): warning #1292: attribute "cleanup" ignored
int __attribute__((cleanup(check_finished))) finished = 0;
Is this a dead-end or am i missing some switch/pragma to enable the support?
#include
#include
void check_finished(int *p) {
if (!*p)
printf("aborted.\\n");
}
int main(int argc, char *argv[]) {
do {
int __attribute__((cleanup(check_finished))) finished = 0;
printf("Begin...");
if (argc > 1 && !strcmp("boo", argv[1]))
break;
printf("end.\\n");
finished = 1;
} while (0);
return 0;
}
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see the bug with the cleanup attribute in 12.0 but it is fixed in 12.1, i.e.:
12.0:
sptxl8-329> icc t.c && ./a.out boo
Begin...sptxl8-330>
12.1:
sptxl8-336> icc t.c && ./a.out boo
Begin...aborted.
sptxl8-337>
Judy
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel C++ Compiler User and Reference Guidedoesn'thave any referencesfor the "cleanup" attribute.
>>...But the "cleanup" doesn't really work...
I wonder if thesetwo highlyportablesolutionsto "cleanup-something"could work for you:
- in case of a C program use 'atexit' CRT function
- in case of a C++ program use adestructor of a static object or 'atexit' CRT function
>>...But the "cleanup" doesn't really work...
I wonder if thesetwo highlyportablesolutionsto "cleanup-something"could work for you:
- in case of a C program use 'atexit' CRT function
- in case of a C++ program use adestructor of a static object or 'atexit' CRT function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The documentation does not appear to be specific on which attributes are actually supported. All I can find is that one may specify them, but that does not appear to mean they are honored. Please, advise if there is in fact a list of supported attributes.
Unfortunately, the task at my hands is C, not C++. And the atexit()-based process-level cleanup is too coarse, I do need it at the scope-level.
More specifically, I need a way to detect/disallow jumping out of the scope with goto, break, continue or return.
I also tried to embark on the documentation's claim on that branching out of the expression statement is not allowed (same page i mentioned above), but that does not seem to match my experiments. Returning and goto-ing out from an expression statement seems to be accepted by the icc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The gcc and icc behaviour is same.
$ gcc -fexceptions tstcase.c
$ ./a.out
Begin...end.
$ icc -fexceptions tstcase.c
$ ./a.out
Begin...end.
I am using icc version Version 12.1.3.293 and gcc 4.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting semenu
...if there is in fact a list of supported attributes.
No, I have not seen it.
Unfortunately, the task at my hands is C, not C++. And the atexit()-based process-level cleanup is too coarse, I do need it at the scope-level.
I see.
No, I have not seen it.
Unfortunately, the task at my hands is C, not C++. And the atexit()-based process-level cleanup is too coarse, I do need it at the scope-level.
I see.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I apologize my example is not self-explanatory. The difference is observed when invoked with "boo" as the first argument. E.g.:
$ gcc slon.c -fexceptions
$ ./a.out
Begin...end.
$ ./a.out boo
Begin...aborted.
$
$ icc slon.c -fexceptions
$ ./a.out
Begin...end.
$ ./a.out boo
Begin...$
$
icc 12.0.5.225. gcc 4.1.2.
$ gcc slon.c -fexceptions
$ ./a.out
Begin...end.
$ ./a.out boo
Begin...aborted.
$
$ icc slon.c -fexceptions
$ ./a.out
Begin...end.
$ ./a.out boo
Begin...$
$
icc 12.0.5.225. gcc 4.1.2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What makes me think the support for the "cleanup" attribute is in fact present in the compiler is that the "icc" binary appears to contain the error strings related to the "cleanup" attribute:
$ strings `which icc` | grep cleanup | grep attribute
attribute_cleanup_requires_automatic_storage
attribute "cleanup" requires automatic storage duration
attribute_cleanup_for_parameter
attribute "cleanup" does not apply to parameters
$ strings `which icc` | grep cleanup | grep attribute
attribute_cleanup_requires_automatic_storage
attribute "cleanup" requires automatic storage duration
attribute_cleanup_for_parameter
attribute "cleanup" does not apply to parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see the bug with the cleanup attribute in 12.0 but it is fixed in 12.1, i.e.:
12.0:
sptxl8-329> icc t.c && ./a.out boo
Begin...sptxl8-330>
12.1:
sptxl8-336> icc t.c && ./a.out boo
Begin...aborted.
sptxl8-337>
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This settles my question indeed. Thanks Judy et al!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page