Results 1 to 6 of 6

Thread: Where are my compiler warnings?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Where are my compiler warnings?

    I've tried to check what the "const ptr" points to when no codeline assigns a value to it. It seems to point to the "hello" string anyway. Does g++ assign uninitialized "const char *"s to the first string in the data section or something?
    I guess I'd better file a bug-report.

  2. #2
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Where are my compiler warnings?

    Try compiling without the -O2 (which performs level 2 optimizations). It sounds like the code is just being optimized out.
    Software Engineer



  3. #3
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Where are my compiler warnings?

    According to the g++ man page, optimization is required for the compiler to be able to notice uninitialized variables.
    I tried compiling with -O1 and without any -O, in neither case do I get a warning about "ptr may be used initialized".

  4. #4
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Where are my compiler warnings?

    There seems to be a lively discussion about how to handle uninitialized variables: http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

Similar Threads

  1. QMdiSubWindow - Warnings while compile
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 3rd February 2009, 15:37
  2. Useless but curious compiler warning question
    By Raccoon29 in forum General Programming
    Replies: 4
    Last Post: 30th July 2008, 20:46
  3. problem to compile exemple qt4 with xlC compiler
    By poulacou in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2008, 14:59
  4. Replies: 7
    Last Post: 24th March 2007, 13:53
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.