[LLVMbugs] [Bug 13323] New: False positive: "Assigned value is garbage or undefined"
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jul 10 16:34:34 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13323
Bug #: 13323
Summary: False positive: "Assigned value is garbage or
undefined"
Product: clang
Version: 3.0
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: adarpodracir at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 8872
--> http://llvm.org/bugs/attachment.cgi?id=8872
A picture showing false positive
Hi there,
The bug I am reporting here has to do with Clang logic error: "Assigned value
is
garbage or undefined". This bug can be reproduced by analyzing the following C
code and using Xcode 4 (more precisely 4.3.3). A picture showing its complains
is also given at this link:
http://i50.tinypic.com/1pxlcj.png
Alternatively, this picture can be found attached.
---------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct XYPoint_type {
double x;
double y;
} XYPoint_t;
XYPoint_t getXYRotPoint(XYPoint_t xyPoint, double theta);
void slicePolygon(XYPoint_t * xyVertex, int numEdges, double a0, double a1);
XYPoint_t getXYRotPoint(XYPoint_t xyPoint, double theta)
{
XYPoint_t xyRotPoint;
xyRotPoint.x=xyPoint.x*cos(theta)+xyPoint.y*sin(theta);
xyRotPoint.y=xyPoint.y*cos(theta)-xyPoint.x*sin(theta);
return xyRotPoint;
}
void slicePolygon(XYPoint_t * xyVertex, const int numEdges, double a0, double
a1)
{
int i=0;
if (xyVertex[0].x!=xyVertex[numEdges].x ||
xyVertex[0].y!=xyVertex[numEdges].y)
{
fprintf(stderr, "Miscellaneous.c::slicePolygon::Error: Polygon is not
closed.");
exit(EXIT_FAILURE);
}
const int numVertices=numEdges+1;
double theta=atan(a1);
//double a=a0*cos(theta);
double array[numEdges];
XYPoint_t xyRotVertex[numVertices];
if (theta==0)
for (i=0; i<numVertices; i++)
xyRotVertex[i]=xyVertex[i];
else
for (i=0; i<numVertices; i++)
xyRotVertex[i]=getXYRotPoint(xyVertex[i], theta);
// Printing xyRotVertex[%i]:
for (i=0; i<numVertices; i++)
printf("xyRotVertex[%i]: (%.5f, %.5f)\n", i, xyRotVertex[i].x,
xyRotVertex[i].y);
for (i=0; i<numEdges; i++)
array[i]=xyRotVertex[i].x;
// Printing array[%i]:
for (i=0; i<numEdges; i++)
printf("array[%i]: %.5f\n", i, array[i]);
// ....
}
int main(void)
{
int numEdges=5;
int numVertices=numEdges+1;
XYPoint_t xyVertex[numVertices];
xyVertex[0].x=0;
xyVertex[0].y=0;
xyVertex[1].x=8.228994;
xyVertex[1].y=0;
xyVertex[2].x=10.771892;
xyVertex[2].y=7.826238;
xyVertex[3].x=4.114497;
xyVertex[3].y=12.663119;
xyVertex[4].x=-2.542899;
xyVertex[4].y=7.826238;
xyVertex[5].x=xyVertex[0].x;
xyVertex[5].y=xyVertex[0].y;
slicePolygon(xyVertex, numEdges, 3.913119, 0);
}
---------------------------------------------------------------------
Thank you very much.
Ricardo.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list