Bug 37740 - [C++0x] "foo f{...}" form compiles, but "new foo{...}" one doesn't
Summary: [C++0x] "foo f{...}" form compiles, but "new foo{...}" one doesn't
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-05 23:52 UTC by Florian Goujeon
Modified: 2008-11-14 22:22 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-11-14 16:23:44


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Goujeon 2008-10-05 23:52:23 UTC
With the following piece of code:

==============================
struct integer
{
    int i;
};

struct foo1
{
    double d;
    int i;
};

struct foo2
{
    double d;
    integer i;
};

int main(int argc, char **argv)
{
    int i1 = 0;
    integer i2{0};

    foo1 f1{3.2, i1}; //ok
    new foo1{3.2, i1}; //ok

    foo2 f2{3.2, i2}; //ok
    new foo2{3.2, i2}; //error, why?

    return 0;
}
==============================

GCC 4.4 svn (4.4.0 20081005) can't compile "new foo2{...}" line:

==============================
$ g++ -std=c++0x main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:53: error: could not convert '{3.20000000000000017763568394002504646778106689453e+0, i2}' to 'foo2'
==============================

though the other lines are OK.

I didn't see anything about a difference between the two forms in the standard, so I guess it is a GCC bug.


$ g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages='c c++' --disable-nls : (reconfigured) ../gcc/configure --enable-languages='c c++' : (reconfigured) ../gcc/configure --enable-languages='c c++' --enable-shared --disable-static --disable-nls
Thread model: posix
gcc version 4.4.0 20081005 (experimental) (GCC)
Comment 1 Paolo Carlini 2008-10-06 08:37:16 UTC
Let's CC Jason...
Comment 2 Jason Merrill 2008-11-14 20:52:24 UTC
Subject: Bug 37740

Author: jason
Date: Fri Nov 14 20:50:59 2008
New Revision: 141865

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141865
Log:
        PR c++/37740
        * call.c (build_aggr_conv): Increment i.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jason Merrill 2008-11-14 22:22:15 UTC
Fixed.