public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36814]  New: G++ won't warn about an uninitialized value
@ 2008-07-12 20:04 jellegeerts at gmail dot com
  2008-08-18 17:37 ` [Bug c++/36814] " manu at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jellegeerts at gmail dot com @ 2008-07-12 20:04 UTC (permalink / raw)
  To: gcc-bugs

Hello,

I've compiled the code below using `g++ -Wuninitialized -O test.cc -o test':

<<<<<<<<<<<<<<<
bool cMyClass::Init()
{
    bool retval;

    if (some_function())
    {
        // If the `goto' is executed, 'return retval;' will use the
        // uninitialized value of 'retval'.
        goto error;
    }

    retval = true;
error:
    return retval;
}
>>>>>>>>>>>>>>>

The problem is explained in the code comments above.

I think that GCC is supposed to warn about this, is that correct?

Thanks, Jelle


-- 
           Summary: G++ won't warn about an uninitialized value
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jellegeerts at gmail dot com
 GCC build triplet: i386-undermydesk-freebsd
  GCC host triplet: i386-undermydesk-freebsd
GCC target triplet: i386-undermydesk-freebsd


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/36814] G++ won't warn about an uninitialized value
  2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
@ 2008-08-18 17:37 ` manu at gcc dot gnu dot org
  2008-08-18 18:15 ` jellegeerts at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-18 17:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2008-08-18 17:35 -------
We need a preprocessed self-contained, preferably small, testcase. Otherwise we
cannot reproduce the bug ourselves.

See http://gcc.gnu.org/bugs.html

Thanks.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
OtherBugsDependingO|                            |24639
              nThis|                            |
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/36814] G++ won't warn about an uninitialized value
  2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
  2008-08-18 17:37 ` [Bug c++/36814] " manu at gcc dot gnu dot org
@ 2008-08-18 18:15 ` jellegeerts at gmail dot com
  2008-08-18 18:16 ` jellegeerts at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jellegeerts at gmail dot com @ 2008-08-18 18:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jellegeerts at gmail dot com  2008-08-18 18:14 -------
Created an attachment (id=16086)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16086&action=view)
output of G++ with the `-v -save-temps' flags


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/36814] G++ won't warn about an uninitialized value
  2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
  2008-08-18 17:37 ` [Bug c++/36814] " manu at gcc dot gnu dot org
  2008-08-18 18:15 ` jellegeerts at gmail dot com
@ 2008-08-18 18:16 ` jellegeerts at gmail dot com
  2008-08-18 18:17 ` jellegeerts at gmail dot com
  2008-08-18 18:57 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jellegeerts at gmail dot com @ 2008-08-18 18:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jellegeerts at gmail dot com  2008-08-18 18:15 -------
Created an attachment (id=16087)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16087&action=view)
the `.ii' file that G++ created


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/36814] G++ won't warn about an uninitialized value
  2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
                   ` (2 preceding siblings ...)
  2008-08-18 18:16 ` jellegeerts at gmail dot com
@ 2008-08-18 18:17 ` jellegeerts at gmail dot com
  2008-08-18 18:57 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jellegeerts at gmail dot com @ 2008-08-18 18:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jellegeerts at gmail dot com  2008-08-18 18:16 -------
Please see the attachments I created for more information.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/36814] G++ won't warn about an uninitialized value
  2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
                   ` (3 preceding siblings ...)
  2008-08-18 18:17 ` jellegeerts at gmail dot com
@ 2008-08-18 18:57 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-18 18:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2008-08-18 18:56 -------
possible_bug.cc:1: error: `cMyClass' has not been declared
possible_bug.cc: In function `bool Init()':
possible_bug.cc:5: error: `some_function' was not declared in this scope
possible_bug.cc:5: warning: unused variable 'some_function'

Anyway, I guess the following reproduces the original problem:

bool some_function(void);

bool Init()
{
    bool retval;

    if (some_function())
    {
        // If the `goto' is executed, 'return retval;' will use the
        // uninitialized value of 'retval'.
        goto error;
    }

    retval = true;
error:
    return retval;
}


which is converted to:

bool Init() ()
{
  boolD.2365 retvalD.2430;
  boolD.2365 retval.0D.2432;

  # BLOCK 2
  # PRED: ENTRY (fallthru,exec)
  [pr36814.C : 7] retval.0D.2432_2 = some_functionD.2427 ();
  [pr36814.C : 7] retval.0D.2432_3 = retval.0D.2432_2;
  [pr36814.C : 7] if (retval.0D.2432_3 != 0)
    goto <bb 4> (error);
  else
    goto <bb 3>;
  # SUCC: 4 (true,exec) 3 (false,exec)

  # BLOCK 3
  # PRED: 2 (false,exec)
  [pr36814.C : 14] retvalD.2430_5 = 1;
  # SUCC: 4 (fallthru,exec)

  # BLOCK 4, starting at line 0
  # PRED: 2 (true,exec) 3 (fallthru,exec)
  # retvalD.2430_1 = PHI <retvalD.2430_4(D)(2), 1(3)>
errorL.1:
  return 1;
  # SUCC: EXIT

}

by the first CCP pass. So this is CCP again.

*** This bug has been marked as a duplicate of 18501 ***


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36814


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-18 18:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-12 20:04 [Bug c++/36814] New: G++ won't warn about an uninitialized value jellegeerts at gmail dot com
2008-08-18 17:37 ` [Bug c++/36814] " manu at gcc dot gnu dot org
2008-08-18 18:15 ` jellegeerts at gmail dot com
2008-08-18 18:16 ` jellegeerts at gmail dot com
2008-08-18 18:17 ` jellegeerts at gmail dot com
2008-08-18 18:57 ` manu at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).