...
| Code Block | ||
|---|---|---|
| ||
char *char_ptr = "example";
int *int_ptr;
int *voidPtr2intPtr(void *v_pointer){
return v_pointer;
}
int_ptr= voidPtr2intPtr(pointerchar_ptr);
|
Pointer might be aligned on even boundary, once it is cast to an int some architectures will require it to be on 4 byte boundaries. Pointers are often cast because a void* cannot be dereferenced. Careless coding can result in an arbitrary pointer type being used irregardless of its alignment.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
DRAFT | 1 (low) | 2 (probable) | 2 (medium) | P4 | L3 |
References
Wiki Markup Bryant, Randal and O'Hallaron, David. \[ 2003 \] 2001 Computer Systems: A Programmer's Perspective. Prentice Hall. ISBN 0-13-034074-X.
- http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf