File: abstptr.c

package info (click to toggle)
splint 1%3A3.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,012 kB
  • ctags: 23,302
  • sloc: ansic: 150,869; yacc: 3,465; sh: 3,034; makefile: 2,160; lex: 412
file content (24 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
typedef int *abst;

/*@noaccess abst*/
int main (void)
{
  abst a;
  int b = 3;
  abst *ap = (abst *) NULL;
  abst *ap2 = NULL;
  void *vp;
  int *ip;

  vp = ap ; /* 1. Assignment of abst * to void *: vp = ap */
  ip = ap2; /* 2. Assignment of abst * to int *: ip = ap2 */
  ap = ip ; /* 3. Assignment of int * to abst *: ap = ip */
  vp = (void *) ap ; /* 4. Cast from underlying abstract type abst *: (void *)ap */
  a = *ap ; /* 5. Possible dereference of null pointer: *ap */    
  *ap = a ;
  vp = (void *)&a ; /* 6. Cast from underlying abstract type abst *: (void *)&a */
  ap = (abst *)&b ; /* 7. Cast to underlying abstract type abst *: (abst *)&b */
  ap = &b; /* 8. Assignment of int * to abst *: ap = &b */
  *ap = b; /* 9. Assignment of int to abst: *ap = b */
  return 12;
}