Web lists-archives.com

Re: [Mingw-users] MinGW Question on versions and Class Constructors

Hi Keith!

On Wed, Mar 23, 2016 at 9:50 AM, Keith Marshall
<keithmarshall@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Hash: SHA1
> On 22/03/16 23:04, Clayton Weaver wrote:
>> I'm using MInGW 4.8.1 which gives me issues with class
>> constructors. For example,
>> class Punct_stream{ public: Punct_stream(istream& is) : source{is},
>> sensitive{true} {} //... private: istream& source; // character
>> source bool sensitive; // is the stream case-sensitive? };
>> The compiler fails with:
>> error: invalid initialization of non-const reference of type
>> 'std::istream& {aka std::basic_istream<char>&}' from an rvalue of
>> type '<brace-enclosed initializer list>'
> FWIW, I see exactly the same when I compile with the native GCC-4.8.2,
> on my LinuxMint Debian system, so this isn't MinGW specific; (I also
> see the same with mingw32-g++ v4.8.2, on the same host).
>> My main question is does this compile correctly in 4.9.3
> Again on the LinuxMint host, the mingw32-g++ v4.9.3 cross-compiler,
> which I used to build the GCC-4.9.3 now offered by MinGW.org, compiles
> it correctly with -std=gnu++11, but not with -std=c++11; the GCC-5.3.0
> cross-compiler, on which I am now working, compiles it correctly with
> either option.

I should have mentioned that with my 4.9.2 mingw-w64 test, I compiled
successfully with "-std=c++11" (as well as with -std=gnu++11, -std=c++14,
and -std=gnu++14).  (As expected, without the -std flag, the compile failed,
because initializer lists are new to c++11.)

It's a little odd that Keith's 4.9.3 needed "-std=gnu++11" to compile Clayton's
code, but my 4.9.2 worked with "-std=c++11".  But, no matter ...

> ...
> Regards,
> Keith.


K. Frank

Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe