code_junkie

GCC: program doesn't work with compilation option -O3

Nov 12th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. struct distanceToPointSort{
  2. indexedDocument* point ;
  3. distanceToPointSort(indexedDocument* p): point(p) {}
  4. bool operator() (indexedDocument* p1,indexedDocument* p2){
  5. return distance(point,p1) < distance(point,p2) ;
  6. }
  7. } ;
  8.  
  9. struct distanceToPointSort{
  10. indexedDocument* point ;
  11. distanceToPointSort(indexedDocument* p): point(p) {}
  12. bool operator() (indexedDocument* p1,indexedDocument* p2){
  13.  
  14. float d1=distance(point,p1) ;
  15. float d2=distance(point,p2) ;
  16.  
  17. std::cout << "" ; //without this line, I get a segmentation fault anyways
  18.  
  19. return d1 < d2 ;
  20. }
  21. } ;
  22.  
  23. g++ -Wall -Wextra -pedantic -ansi
  24.  
  25. #include <stdio.h>
  26.  
  27. int main()
  28. {
  29. int i = 0, j = 1, k = 2;
  30. printf("%d %d %dn", *(&j-1), *(&j), *(&j+1));
  31. return 0;
  32. }
  33.  
  34. volatile float d1=distance(point,p1) ;
  35. volatile float d2=distance(point,p2) ;
  36. return d1 < d2 ;
  37.  
  38. struct distanceToPointSort{
  39. indexedDocument* point ;
  40. distanceToPointSort(indexedDocument* p): point(p) {}
  41. bool operator() (indexedDocument* p1,indexedDocument* p2){
  42. return distance(point,p1) < distance(point,p2) ;
  43. }
  44. } ;
  45.  
  46. struct distanceToPointSort{
  47. indexedDocument* point ;
  48. distanceToPointSort(indexedDocument* p): point(p) {}
  49. bool operator() (indexedDocument* p1,indexedDocument* p2){
  50.  
  51. float d1=distance(point,p1) ;
  52. float d2=distance(point,p2) ;
  53.  
  54. std::cout << "" ; //without this line, I get a segmentation fault anyways
  55.  
  56. return d1 < d2 ;
  57. }
  58. } ;
Add Comment
Please, Sign In to add comment