Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <new>
  2. #include <stdio.h>
  3.  
  4. struct F
  5. {
  6.  float f,g;
  7. };
  8.  
  9. struct I
  10. {
  11.   int i[2];
  12. };
  13.  
  14.  
  15. struct I ginput;
  16.  
  17. struct I* __attribute__((noipa))
  18. get_I ()
  19. {
  20.   return &ginput;
  21. }
  22.  
  23. volatile float float_input;
  24.  
  25. float  __attribute__((noipa))
  26. get_float_1 ()
  27. {
  28.   return float_input + 1;
  29. }
  30.  
  31. struct I goutput;
  32. struct F gf_distraction;
  33. int never_true;
  34.  
  35.  
  36.  
  37. void  __attribute__((noipa))
  38. foo ()
  39. {
  40.   struct I s;
  41.  
  42.   if (never_true)
  43.     {
  44.       struct F *p = new (&s) F;
  45.       p->f = get_float_1 ();
  46.       p->g = get_float_1 ();
  47.       gf_distraction = *p;
  48.     }
  49.   else
  50.     {
  51.       struct I *t = get_I ();
  52.       s = *t;
  53.       goutput = s;
  54.     }
  55. }
  56.  
  57.  
  58. int
  59. main ()
  60. {
  61.   ginput.i[0] = 15;
  62.   ginput.i[1] = -202;
  63.   foo();
  64.   fprintf (stderr, "goutput[0]: %i\n", goutput.i[0]);
  65.   fprintf (stderr, "goutput[1]: %i\n", goutput.i[1]);
  66.  
  67.   return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement