public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38517]  New: At definition of the empty reference the error is not output.
@ 2008-12-13 17:39 lisp2d at lisp2d dot net
  2008-12-16  0:12 ` [Bug c++/38517] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: lisp2d at lisp2d dot net @ 2008-12-13 17:39 UTC (permalink / raw)
  To: gcc-bugs

int& i; //ok


-- 
           Summary: At definition of the empty reference the error is not
                    output.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lisp2d at lisp2d dot net


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


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

* [Bug c++/38517] At definition of the empty reference the error is not output.
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
@ 2008-12-16  0:12 ` pinskia at gcc dot gnu dot org
  2008-12-16  0:14 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-16  0:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-12-16 00:11 -------
t.c:1: error: 'i' declared as reference but not initialized

Why do you think this is valid code?  Reference variables have to be
initialized.


-- 


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


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

* [Bug c++/38517] At definition of the empty reference the error is not output.
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
  2008-12-16  0:12 ` [Bug c++/38517] " pinskia at gcc dot gnu dot org
@ 2008-12-16  0:14 ` pinskia at gcc dot gnu dot org
  2008-12-16  5:54 ` lisp2d at lisp2d dot net
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-16  0:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-12-16 00:12 -------
extern int &i;
is valid though.  Note in C, int i; is a tentative definition while in C++,
there is no such thing as a tentative definition so it is normal definition and
therefor since it is a reference type variable, it has to be initialized.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/38517] At definition of the empty reference the error is not output.
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
  2008-12-16  0:12 ` [Bug c++/38517] " pinskia at gcc dot gnu dot org
  2008-12-16  0:14 ` pinskia at gcc dot gnu dot org
@ 2008-12-16  5:54 ` lisp2d at lisp2d dot net
  2008-12-16 19:20 ` [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: lisp2d at lisp2d dot net @ 2008-12-16  5:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from lisp2d at lisp2d dot net  2008-12-16 05:52 -------
More exact example:

.h:

extern int& i;

.cpp:

int& i; // ok


-- 


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


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

* [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
                   ` (2 preceding siblings ...)
  2008-12-16  5:54 ` lisp2d at lisp2d dot net
@ 2008-12-16 19:20 ` pinskia at gcc dot gnu dot org
  2008-12-16 19:20 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-16 19:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-12-16 19:18 -------
Simple testcase:
extern int& i;
int& i; // ERROR: this is not ok


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|0000-00-00 00:00:00         |2008-12-16 19:18:00
               date|                            |
            Summary|At definition of the empty  |Uninitialized reference
                   |reference the error is not  |variable is accepted after
                   |output.                     |an extern declaration


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


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

* [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
                   ` (3 preceding siblings ...)
  2008-12-16 19:20 ` [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration pinskia at gcc dot gnu dot org
@ 2008-12-16 19:20 ` pinskia at gcc dot gnu dot org
  2008-12-18  9:40 ` jakub at gcc dot gnu dot org
  2010-01-04 20:26 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-16 19:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2008-12-16 19:18 -------
Not a regression.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.3.3 4.0.0 4.3.0 4.4.0


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


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

* [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
                   ` (4 preceding siblings ...)
  2008-12-16 19:20 ` pinskia at gcc dot gnu dot org
@ 2008-12-18  9:40 ` jakub at gcc dot gnu dot org
  2010-01-04 20:26 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-18  9:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-12-18 09:39 -------
4297  if (init == NULL_TREE)
4298    {
4299      if ((DECL_LANG_SPECIFIC (decl) == 0
4300           || DECL_IN_AGGR_P (decl) == 0)
4301          && ! DECL_THIS_EXTERN (decl))
4302        error ("%qD declared as reference but not initialized", decl);
4303      return NULL_TREE;
4304    }

DECL_THIS_EXTERN is sticky, if something has been ever declared with extern, it
is preserved through duplicate_decls.  I wonder why this doesn't use
&& ! DECL_EXTERNAL (decl) instead.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration
  2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
                   ` (5 preceding siblings ...)
  2008-12-18  9:40 ` jakub at gcc dot gnu dot org
@ 2010-01-04 20:26 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-04 20:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2010-01-04 20:26 -------


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


-- 

jason at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2010-01-04 20:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-13 17:39 [Bug c++/38517] New: At definition of the empty reference the error is not output lisp2d at lisp2d dot net
2008-12-16  0:12 ` [Bug c++/38517] " pinskia at gcc dot gnu dot org
2008-12-16  0:14 ` pinskia at gcc dot gnu dot org
2008-12-16  5:54 ` lisp2d at lisp2d dot net
2008-12-16 19:20 ` [Bug c++/38517] Uninitialized reference variable is accepted after an extern declaration pinskia at gcc dot gnu dot org
2008-12-16 19:20 ` pinskia at gcc dot gnu dot org
2008-12-18  9:40 ` jakub at gcc dot gnu dot org
2010-01-04 20:26 ` jason 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).