public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly
@ 2004-07-03 12:41 matthew_bugzilla at datadeliverance dot com
  2004-07-03 18:39 ` [Bug c++/16347] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: matthew_bugzilla at datadeliverance dot com @ 2004-07-03 12:41 UTC (permalink / raw)
  To: gcc-bugs

This seems to be a manifestation of the problem documented as resolved in the
3.4 series compilers: if you try to create an object and pass in a temporary
object as a parameter, it still sometimes parses it as a function prototype,
even though parameter(s) are being passed to the constructor of the temporary
object.  This seems to happen only if you pass a variable to the temporary
object's constructor, not if you pass a literal.  The workarounds for the
original manifestation of these bugs in the pre-3.4 compilers seem to fix this
one also.

Simple example below:

------------------------------
class A
{
public:
 A(int);
};

class B
{
public:
 B(A);
 int val;
};

main()
{
 int i;
 //B b(A(1));      // This works ok
 //B b((A(i))); // This works too
 B b(A(i));   // This doesn't
 b.val = 2;
}
------------------------------------


Output of g++:

$ /usr/local/gcc-3.5-20040627/bin/g++ -v foo2.cpp
Reading specs from /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/specs
Configured with: /usr/local/src/gcc-3.5-20040627/configure
--prefix=/usr/local/gcc-3.5-20040627
Thread model: posix
gcc version 3.5.0 20040627 (experimental)
 /usr/local/gcc-3.5-20040627/libexec/gcc/i686-pc-linux-gnu/3.5.0/cc1plus -quiet
-v -D_GNU_SOURCE foo2.cpp -quiet -dumpbase foo2.cpp -mtune=pentiumpro -auxbase
foo2 -version -o /tmp/cc2cbynF.s
ignoring nonexistent directory
"/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0
 /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0/i686-pc-linux-gnu
 /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0/backward
 /usr/local/include
 /usr/local/gcc-3.5-20040627/include
 /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/include
 /usr/include
End of search list.
GNU C++ version 3.5.0 20040627 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.5.0 20040627 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
foo2.cpp: In function `int main()':
foo2.cpp:21: error: request for member `val' in `b', which is of non-class type
`B ()(A)'

-- 
           Summary: Some cases of calling constructor with temporary object
                    still not recognised properly
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: matthew_bugzilla at datadeliverance dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
@ 2004-07-03 18:39 ` pinskia at gcc dot gnu dot org
  2004-07-05  6:03 ` matthew_bugzilla at datadeliverance dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-03 18:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-03 18:39 -------
 B b(A(i));   // This doesn't
means a function which returns the type B and takes A as an agrument,

So this is not a bug, there has been a couple of dups like this before.

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


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
  2004-07-03 18:39 ` [Bug c++/16347] " pinskia at gcc dot gnu dot org
@ 2004-07-05  6:03 ` matthew_bugzilla at datadeliverance dot com
  2004-07-05  8:51 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: matthew_bugzilla at datadeliverance dot com @ 2004-07-05  6:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From matthew_bugzilla at datadeliverance dot com  2004-07-05 06:03 -------
(In reply to comment #1)
>  B b(A(i));   // This doesn't
> means a function which returns the type B and takes A as an agrument,
> So this is not a bug, there has been a couple of dups like this before.

I can see that B b(A) means that, but surely B b(A(i)) can't be a function 
declaration - what does the (i) mean in that case?  And why does it correctly 
interpret B b(A(1)) as instantiating a B?

Thanks

             -Matthew

-- 


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
  2004-07-03 18:39 ` [Bug c++/16347] " pinskia at gcc dot gnu dot org
  2004-07-05  6:03 ` matthew_bugzilla at datadeliverance dot com
@ 2004-07-05  8:51 ` pinskia at gcc dot gnu dot org
  2004-07-05 21:30 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-05  8:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-05 08:51 -------
because 1 is not identifer but a constant.

See PR 16056, and a couple of others which I cannot find at this point.

This is ambiguous which the standard decided that thiis declares a function rather than a variable so 
this is still invalid.

-- 


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
                   ` (2 preceding siblings ...)
  2004-07-05  8:51 ` pinskia at gcc dot gnu dot org
@ 2004-07-05 21:30 ` bangerth at dealii dot org
  2004-08-17 10:47 ` pinskia at gcc dot gnu dot org
  2004-08-17 10:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-07-05 21:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-07-05 21:30 -------
This
  B b(A(i))
is interpreted as if you wrote
  B b(A i)
which is the declaration of a function 'b' returning a 'B', and taking a
variable 'i' of type 'A' as arguments.

Yes, that sounds odd, but that's what the grammar seems to say.

W.

-- 


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
                   ` (3 preceding siblings ...)
  2004-07-05 21:30 ` bangerth at dealii dot org
@ 2004-08-17 10:47 ` pinskia at gcc dot gnu dot org
  2004-08-17 10:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17 10:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 10:47 -------
*** Bug 17062 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei dot mischenko at mail
                   |                            |dot ru


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


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

* [Bug c++/16347] Some cases of calling constructor with temporary object still not recognised properly
  2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
                   ` (4 preceding siblings ...)
  2004-08-17 10:47 ` pinskia at gcc dot gnu dot org
@ 2004-08-17 10:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17 10:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 10:49 -------
*** Bug 12427 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |igodard at pacbell dot net


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


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

end of thread, other threads:[~2004-08-17 10:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-03 12:41 [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly matthew_bugzilla at datadeliverance dot com
2004-07-03 18:39 ` [Bug c++/16347] " pinskia at gcc dot gnu dot org
2004-07-05  6:03 ` matthew_bugzilla at datadeliverance dot com
2004-07-05  8:51 ` pinskia at gcc dot gnu dot org
2004-07-05 21:30 ` bangerth at dealii dot org
2004-08-17 10:47 ` pinskia at gcc dot gnu dot org
2004-08-17 10:49 ` 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).