Thread: Problem with compiling code with option -O2

  1. #16
    Registered User
    Join Date
    Jan 2009
    Posts
    7
    May be it is another trap or pitfall of C. But at least, The compiler should give a warning to programmers.

  2. #17
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    May be it is another trap or pitfall of C.
    I do not agree, this has nothing to do with C, this is an optimization issue and the standard says nothing about it. Plus this is a 'known' problem (or it should be): when you try to optimize (too much) some code, you're no longer ensured to get a correct result (except if you select carefully which optimizations you want and if you know what the optimizer will do). Nobody forces you to use the optimizer, this is a bonus (to use with caution).

    The compiler should give a warning to programmers.
    There is the -Wstrict-aliasing warning despite it does not help much in this case. Last versions of gcc surely have better support (-Wstrict-aliasing=2), but I didn't try.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  2. Help on compiling code
    By mattyp1977 in forum C++ Programming
    Replies: 4
    Last Post: 03-26-2006, 05:07 PM
  3. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Big Code, Little Problem
    By CodeMonkey in forum Windows Programming
    Replies: 4
    Last Post: 10-03-2001, 05:14 PM

Tags for this Thread