Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   constexpr constructor: A bug in GCC 4.5.0 (http://www.velocityreviews.com/forums/t744998-constexpr-constructor-a-bug-in-gcc-4-5-0-a.html)

Saeed Amrollahi 03-12-2011 01:46 PM

constexpr constructor: A bug in GCC 4.5.0
 
Dear All
Hi

AFAIK, A constexpr constructor is a simple constructor that it must
initialize the data members in the
member-initializer part and those initializations must involve only
potential constant expressions, and its body is empty.

The following class is compiled without error under g++ 4.5.0
// point.c++
struct Point {
int x, y;
constexpr point(int xx, int yy) : x(xx), y(yy) {}
constexpr point() { x = y = 0; } // constexpr constructor with non-
empty body
};

I used the following command for compilation:
g++ -c -std=c++0x point.c++ -o point

Is it a bug in g++?

-- Saeed Amrollahi

Marc 03-12-2011 02:23 PM

Re: constexpr constructor: A bug in GCC 4.5.0
 
Saeed Amrollahi wrote:

> AFAIK, A constexpr constructor is a simple constructor that it must
> initialize the data members in the
> member-initializer part and those initializations must involve only
> potential constant expressions, and its body is empty.
>
> The following class is compiled without error under g++ 4.5.0
> // point.c++
> struct Point {
> int x, y;
> constexpr point(int xx, int yy) : x(xx), y(yy) {}
> constexpr point() { x = y = 0; } // constexpr constructor with non-
> empty body
> };


Use the same capitalization for Point everywhere...

> I used the following command for compilation:
> g++ -c -std=c++0x point.c++ -o point
>
> Is it a bug in g++?


g++-4.5 did not implement constexpr, just some super-crude version to
let some code compile. g++-4.6 does way better:
In constructor 'constexpr point::point()':
error: uninitialized member 'point::x' in 'constexpr' constructor
error: constexpr constructor does not have empty body

Saeed Amrollahi 03-12-2011 02:59 PM

Re: constexpr constructor: A bug in GCC 4.5.0
 
On Mar 12, 5:23*pm, Marc <marc.gli...@gmail.com> wrote:
> Saeed Amrollahi *wrote:
> > AFAIK, A constexpr constructor is a simple constructor that it must
> > initialize the data members in the
> > member-initializer part and those initializations must involve only
> > potential constant expressions, and its body is empty.

>
> > The following class is compiled without error under g++ 4.5.0
> > // point.c++
> > struct Point {
> > * *int x, y;
> > * *constexpr point(int xx, int yy) : x(xx), y(yy) {}
> > * *constexpr point() { x = y = 0; } *// constexpr constructorwith non-
> > empty body
> > };

>
> Use the same capitalization for Point everywhere...
>

Oh Sorry.
> > I used the following command for compilation:
> > g++ -c -std=c++0x point.c++ -o point

>
> > Is it a bug in g++?

>
> g++-4.5 did not implement constexpr, just some super-crude version to
> let some code compile. g++-4.6 does way better:

Yes I checked that and you are right.
> In constructor 'constexpr point::point()':
> error: uninitialized member 'point::x' in 'constexpr' constructor
> error: constexpr constructor does not have empty body

AFAIK, GCC hasn't release the g++ 4.6.0 yet (http://gcc.gnu.org)
How can I access/download the g++ 4.6.0?

TIA,
-- Saeed Amrollahi

Marc 03-12-2011 03:56 PM

Re: constexpr constructor: A bug in GCC 4.5.0
 
Saeed Amrollahi wrote:

> AFAIK, GCC hasn't release the g++ 4.6.0 yet (http://gcc.gnu.org)
> How can I access/download the g++ 4.6.0?


You are right that it isn't released yet, I was talking of the current
development version. http://gcc.gnu.org, top right corner, below
"Releases", "Snapshots". For debian users (possibly ubuntu as well),
there is also a gcc-snapshot package in the distribution.


All times are GMT. The time now is 02:22 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.