Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"

erling_andersen
New Contributor I
4,803 Views

How should the warning:

src/mosek/mosekopt.c(1893): warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"

char *pri_par_list[] = {"MSK_IPAR_CONCURRENT_PRIORITY_INTPNT","MSK_IPAR_CONCURRENT_PRIORITY_PRIMAL_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_DUAL_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_FREE_SIMPLEX"};

be understood and how to fix it.

It sort of says char * is not the same as char *-

Erling

PS: It is verion 13 of Intel C at Linux.

0 Kudos
9 Replies
Georg_Z_Intel
Employee
4,803 Views
Hello, that's odd. Could you please provide me the compiler options used in order to reproduce the problem? Thank you & best regards, Georg Zitzlsberger
0 Kudos
erling_andersen
New Contributor I
4,803 Views

/remote/public/linux/opt/intel/composer_xe_2013.0.079/bin/intel64/icc -o bld/gram/final/default/intelc-13.0.0/dll/mosek-objs/mosekopt.o -c -DSYST\
HREADING=1 -DSYSPTHREAD=1 -DEXTERNPTHREAD -O2 -mp1 -inline-level=2 -DSYSTHREADING=1 -DSYSPTHREAD=1 -DEXTERNPTHREAD -xSSE2 -DBLDTOOL_INTELC -DLINU\
X64X86=1 -D_CPU_GENERIC_ -DSYSOPENMP -w1 -Wp64 -Wcheck -Wmissing-prototypes -diag-disable 913 -Wuninitialized -malign-double -prec_div -gcc-name=\
/remote/public/linux/64-x86/gcc/4.5.2/bin/gcc -gxx-name=/remote/public/linux/64-x86/gcc/4.5.2/bin/g++ -gcc-version=450 -openmp -openmp-link=dynam\
ic -DSYSRESTRICT -restrict -DSYSMT -DMSKCONST= -DSYSRELEASE=0 -DSYSDEBUG=0 -D_MOSEKDEV=0 -DNDEBUG -DCCVERSION=13.0.0 -fPIC -Isrc/basic -Isrc/cpub\
-Isrc/dualize -Isrc/homo -Isrc/kfac -Isrc/lalib -Isrc/lu -Isrc/math -Isrc/misc -Isrc/netopt -Isrc/network -Isrc/optimize -Isrc/order -Isrc/pivot\
-Isrc/prslv -Isrc/simplex -Isrc/temp -Isrc/thread -Isrc/mio/extern -Ibld/gram/final/default/intelc-13.0.0/src/ivec -Isrc/mosek -Ibld/gram/final/\
default/intelc-13.0.0/src/mosek -I/remote/public/linux/64-x86/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/install-tools/include -I/remote/pu\
blic/linux/64-x86/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/install-tools/include src/mosek/mosekopt.c
src/mosek/mosekopt.c(1893): warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"
char *pri_par_list[] = {"MSK_IPAR_CONCURRENT_PRIORITY_INTPNT","MSK_IPAR_CONCURRENT_PRIORITY_PRIMAL_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_DUA\
L_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_FREE_SIMPLEX"};

0 Kudos
Georg_Z_Intel
Employee
4,803 Views
Hello, Thank you for the information! Unfortunately I'm still not able to reproduce it. I suspect that the problem is somewhere in the front-end due to the "complexity" of the preprocessed source file. Hence I'm asking you whether it would be possible to provide the preprocessed file (option -P). You can sent it directly to me via the "Send author a message" link above. Thank you & best regards, Georg Zitzlsberger
0 Kudos
SergeyKostrov
Valued Contributor II
4,803 Views
Hi Georg, >>...Unfortunately I'm still not able to reproduce it... What extension for a source file with the test case did you use? A .c or .cpp?
0 Kudos
Georg_Z_Intel
Employee
4,803 Views
Hello Sergey, same file name as Erling has used: mosekopt.c Best regards, Georg Zitzlsberger
0 Kudos
Judith_W_Intel
Employee
4,803 Views

I think the warning is telling you that you shouldn't be trying to initialize a char* with a string literal (which is non writable).

This is the warning the latest icc and gcc would give if you used the -Wwrite-strings option:

sptxl8-510> gcc -Wwrite-strings -c t.c
t.c:2: warning: initialization discards qualifiers from pointer target type
sptxl8-511> icc -Wwrite-strings -c t.c
t.c(2): warning #3179: deprecated conversion of string literal to char* (should be const char*)
  char* c[] = { "abc" };
                ^

sptxl8-512>

0 Kudos
SergeyKostrov
Valued Contributor II
4,803 Views
Hi everybody, >>char *pri_par_list[] = >>{ >>"MSK_IPAR_CONCURRENT_PRIORITY_INTPNT", >>"MSK_IPAR_CONCURRENT_PRIORITY_PRIMAL_SIMPLEX", >>"MSK_IPAR_CONCURRENT_PRIORITY_DUAL_SIMPLEX", >>"MSK_IPAR_CONCURRENT_PRIORITY_FREE_SIMPLEX" >>}; The way erling_andersen initializes the array is absolutely classic and there are no any errors with it. However, I would: - Ignore that warning because in that case everything is correct - Add "" ( empty string ) at the end of array ( this is simply my style... ): char *pri_par_list[] = { "MSK_IPAR_CONCURRENT_PRIORITY_INTPNT", "MSK_IPAR_CONCURRENT_PRIORITY_PRIMAL_SIMPLEX", "MSK_IPAR_CONCURRENT_PRIORITY_DUAL_SIMPLEX", "MSK_IPAR_CONCURRENT_PRIORITY_FREE_SIMPLEX", "" };
0 Kudos
erling_andersen
New Contributor I
4,803 Views

It is .c file. 

You right I can ignore the warning but it is VERY annoying to get warnings for things that is correct. It devalues the value of warnings.

Btw actually I would like to have

const char *pri_par_list[] = {"MSK_IPAR_CONCURRENT_PRIORITY_INTPNT","MSK_IPAR_CONCURRENT_PRIORITY_PRIMAL_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_DUA\

L_SIMPLEX","MSK_IPAR_CONCURRENT_PRIORITY_FREE_SIMPLEX"};

but that also cause warnings. I think the const is more correct since you cannot change the strings.

  

   

0 Kudos
Georg_Z_Intel
Employee
4,803 Views
Hello Erling, I'm still offering help to narrow down the problem starting with the preprocessed file, if you wish. Alternatively you could shrink it down to some small reproducer as well and send it to us for analysis. Best regards, Georg Zitzlsberger
0 Kudos
Reply