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

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

erling_andersen的头像

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.

10 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Georg Zitzlsberger (Intel)的头像

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

erling_andersen的头像

/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"};

Georg Zitzlsberger (Intel)的头像

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

Sergey Kostrov的头像

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?

Georg Zitzlsberger (Intel)的头像

Hello Sergey,

same file name as Erling has used: mosekopt.c

Best regards,

Georg Zitzlsberger

Judith Ward (Intel)的头像

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>

Sergey Kostrov的头像

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",
""
};

erling_andersen的头像

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.

  

   

Georg Zitzlsberger (Intel)的头像

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

登陆并发表评论。