sscanf not working good in icl 12.0.5

sscanf not working good in icl 12.0.5

Below code is working good in 10.1.0.32 but failing to produce correct outputin 12.0.5working env :: win2k8 R2 64-bti#includeint main(){char buf[100]="ORACORE 4 6 0 1 2# none alpha";char ver[100];char prod[101];int v1, v2, v3, v4, v5;char vc=10;char dist[102];const char *distptr;char reltype[5];int rtype;sscanf((const char *)buf, "%s%d%d%d%d%d%c%s%s", prod, &v1, &v2, &v3, &v4, &v5, &vc, dist, reltype);printf("buf ::%s\\n",buf);printf("sscanf ::*%s*\\n*%d*\\n*%d*\\n*%d*\\n*%d*\\n*%d*\\nvc::%d\\n*%s*\\n*%s*\\n",prod, v1, v2, v3, v4, v5, vc, dist, reltype);}

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

thank you for letting us know and with a testcase.

I'll file the bug and get it fixed. It does not with 13.0 beta as well.

btw, the latest production compiler is 12.1 update 10. your version is a little old.

Jennifer

This is what I am getting:

T:\WORK>icl scan.cpp
Intel C++ Compiler XE for applications running on IA-32, Version 13.0.0.041 Beta Build 20120425
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

scan.cpp
Microsoft Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:scan.exe
scan.obj

T:\WORK>scan
buf ::
sscanf ::*ORACORE*
*4*
*6*
*0*
*1*
*2*
vc::35
*none*
*alpha*

-- Regards, Igor Levicki If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.

Our engineer found that the following var is too small. I should have read the code more carefully as well.
If you change the "5" to "6", it works great. It is an user error in this case.

char reltype[5];

Jennifer

Thanks a lot.
I understood the mistake i didAs there is no space for NULL character it is placing NULL in next memory address which was already allocated to variable v1. Hence 4 is overwritten with 0.I didn't know that all char arrays will be allocated memory consecutively on stack irrespective of the order in which they are declared in the program.Thanks for looking into it.Naveen

Leave a Comment

Please sign in to add a comment. Not a member? Join today