public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/18635] [DR 504] use of uninitialised reference accepted (without -Wuninitialized) in C++ front end
Date: Thu, 08 Apr 2021 00:20:41 +0000	[thread overview]
Message-ID: <bug-18635-4-U3eDZl6IJI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-18635-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #18 from Martin Sebor <msebor at gcc dot gnu.org> ---
What is this a request for?

GCC 11 issues the warnings below, as well as for most of the test cases here. 
Since (I assume most of us agree) rejecting the code would not be
correct/conforming, is there something else to enhance?   (There are
bugs/limitations in -Wuninitialized that prevent diagnosing some similar cases
but I'd expect to track those as bugs separately from this request.)

$ cat t.C && gcc -S -Wall t.C
const int* fcp (const int *);

void gcp ()
{
  const int *p = fcp (p);    // -Wuninitialized
}

const int& fcr (const int &);

void gcr ()
{
  const int &i = fcr (i);    // -Wuninitialized
}

int& fr (int &);

void gr ()
{
  int &r = fr (r);           // -Wuninitialized
}

t.C: In function ‘void gcp()’:
t.C:5:22: warning: ‘p’ is used uninitialized [-Wuninitialized]
    5 |   const int *p = fcp (p);    // -Wuninitialized
      |                  ~~~~^~~
t.C:5:14: note: ‘p’ was declared here
    5 |   const int *p = fcp (p);    // -Wuninitialized
      |              ^
t.C: In function ‘void gcr()’:
t.C:12:22: warning: ‘i’ is used uninitialized [-Wuninitialized]
   12 |   const int &i = fcr (i);    // -Wuninitialized
      |                  ~~~~^~~
t.C:12:14: note: ‘i’ was declared here
   12 |   const int &i = fcr (i);    // -Wuninitialized
      |              ^
t.C: In function ‘void gr()’:
t.C:19:15: warning: ‘r’ is used uninitialized [-Wuninitialized]
   19 |   int &r = fr (r);           // -Wuninitialized
      |            ~~~^~~
t.C:19:8: note: ‘r’ was declared here
   19 |   int &r = fr (r);           // -Wuninitialized
      |        ^

  parent reply	other threads:[~2021-04-08  0:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-18635-4@http.gcc.gnu.org/bugzilla/>
2010-11-26  1:05 ` [Bug c++/18635] use of uninitialised reference accepted " adam.rak at streamnovation dot com
2010-11-26 11:23 ` redi at gcc dot gnu.org
2010-11-26 11:29 ` manu at gcc dot gnu.org
2010-11-26 12:00 ` redi at gcc dot gnu.org
2010-11-26 17:28 ` pentek.imre at gmail dot com
2010-11-26 18:40 ` redi at gcc dot gnu.org
2010-11-27 14:53 ` adam.rak at streamnovation dot com
2011-05-22 19:11 ` redi at gcc dot gnu.org
2011-06-27 11:55 ` [Bug c++/18635] [DR 504] " redi at gcc dot gnu.org
2021-04-08  0:20 ` msebor at gcc dot gnu.org [this message]
2021-04-08  8:16 ` [Bug c++/18635] [DR 504] use of uninitialised reference accepted (without -Wuninitialized) " manu at gcc dot gnu.org
2021-04-08 14:24 ` msebor at gcc dot gnu.org
2021-08-10 19:46 ` redi at gcc dot gnu.org
2024-04-12  0:06 ` mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-18635-4-U3eDZl6IJI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).