public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18000] New: g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries
@ 2004-10-14 15:08 schveiguy at yahoo dot com
  2004-10-14 15:48 ` [Bug c++/18000] " nathan at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: schveiguy at yahoo dot com @ 2004-10-14 15:08 UTC (permalink / raw)
  To: gcc-bugs

Platform: x86 (Pentium 4 2.8 GHz with MT)

The following code does not compile, it appears that g++ is interpreting the 
declaration of myvar to be a function prototype:

steves@linux:~> g++3.4.2 -v
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: ./configure --program-suffix=3.4.2
Thread model: posix
gcc version 3.4.2
steves@linux:~> g++3.4.2 -Wall -o testcpp testcpp.cpp
testcpp.cpp: In function `int main(int, char**)':
testcpp.cpp:19: error: request for member `m' in `myvar', which is of non-class
type `x ()(y)'
testcpp.cpp:17: warning: unused variable 'v'
testcpp.cpp:19: warning: unused variable 'v2'
steves@linux:~>

The code:

class y
{
public:
        y(int n) : n(n) {}
        int n;
};

class x
{
public:
        x(y m) : m(m) {}
        y m;
};

int main(int argc, char *argv[])
{
        int v = 1;
        x myvar(y(v));
        int v2 = myvar.m.n;
}

-- 
           Summary: g++ interprets a variable declaration as a function
                    prototype when the arguments to the constructor are
                    temporaries
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schveiguy at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/18000] g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries
  2004-10-14 15:08 [Bug c++/18000] New: g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries schveiguy at yahoo dot com
@ 2004-10-14 15:48 ` nathan at gcc dot gnu dot org
  2004-10-14 19:51 ` schveiguy at yahoo dot com
  2005-07-17 15:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-10-14 15:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-10-14 15:48 -------
This is correct behaviour. [8.2]

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/18000] g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries
  2004-10-14 15:08 [Bug c++/18000] New: g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries schveiguy at yahoo dot com
  2004-10-14 15:48 ` [Bug c++/18000] " nathan at gcc dot gnu dot org
@ 2004-10-14 19:51 ` schveiguy at yahoo dot com
  2005-07-17 15:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: schveiguy at yahoo dot com @ 2004-10-14 19:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schveiguy at yahoo dot com  2004-10-14 19:51 -------
(In reply to comment #1)
> This is correct behaviour. [8.2]

whoops!  I'll be damned.  It doesn't seem like it should be proper behavior :) 
sorry.  Thanks for the quick reply.

If anyone reads this bug, and has a similar problem, the fix for the code 
above is to change the line to:

x myvar = x(y(v));

-- 


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


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

* [Bug c++/18000] g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries
  2004-10-14 15:08 [Bug c++/18000] New: g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries schveiguy at yahoo dot com
  2004-10-14 15:48 ` [Bug c++/18000] " nathan at gcc dot gnu dot org
  2004-10-14 19:51 ` schveiguy at yahoo dot com
@ 2005-07-17 15:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-17 15:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-17 15:56 -------
*** Bug 22520 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ccarena at cox dot net


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


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

* [Bug c++/18000] g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries
       [not found] <bug-18000-9470@http.gcc.gnu.org/bugzilla/>
@ 2006-08-14 20:43 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-14 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-08-14 20:42 -------
*** Bug 28728 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mceier at gmail dot com


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


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

end of thread, other threads:[~2006-08-14 20:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-14 15:08 [Bug c++/18000] New: g++ interprets a variable declaration as a function prototype when the arguments to the constructor are temporaries schveiguy at yahoo dot com
2004-10-14 15:48 ` [Bug c++/18000] " nathan at gcc dot gnu dot org
2004-10-14 19:51 ` schveiguy at yahoo dot com
2005-07-17 15:57 ` pinskia at gcc dot gnu dot org
     [not found] <bug-18000-9470@http.gcc.gnu.org/bugzilla/>
2006-08-14 20:43 ` pinskia 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).