Treating __func__ and __FUNCTION__ as string literals

Ref no: DPD200158730

Problem : 
__FUNCTION__ macro not treated as string literal

Environment : Linux C++

Root Cause/Details : 
For the pre-defined symbol __FUNCTION__, Although icpc expands it correctly, it doesn't treat it as a string literal for the purposes of string concatenation etc, and hence result in compile error. On the other hand, all of the following statements compile correctly:

printf("date = %s\n", "FOO" __DATE__);
printf("file = %s\n", "FOO" __FILE__);
printf("time = %s\n", "FOO" __TIME__);

__FUNCTION__ should also work similarly.

Resolution : 
This issue will be fixed in the latest 12.0 release in Linux, if we use the -Qoption,cpp,<option> , like in below sample code shows.

Sample code compilation :

#include <stdio.h>

char a[] = __func__;
char b[] = __FUNCTION__;

int main() {
  printf(a);   // this should not print
  printf(b);   // this also should print nothing

icpc -Qoption,cpp,--treat_func_as_string_literal_cpp tr.cpp


If we do not use the option --treat_func_as_string_literal_cpp, or just use --treat_func_as_string_literal
in the current compilers like 10.x or 11.x, then the code will not compile, and to compile it, we will need comma speration , as the macro __func__ is not treated as string and cannot be concatenated.
  This is fixed and will be released in later versions from 12.0.

[DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]

For more complete information about compiler optimizations, see our Optimization Notice.