Re: c++11 issue with static constexpr member initializer, constexpr constructor and member function pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Interesting; I tried it on gcc 4.8.3 (for arm-none-eabi- target), and
I did not see the problem. So it may indeed be a regression.

Sorry about all the formatting issues.Here is re-posting without
horrible =3D inserted everywhere:

template <typename T>
struct Bar
{
    using MemberFuncT = int (T::*)();

    MemberFuncT h_;
    constexpr Bar(MemberFuncT h) : h_{h}
    {
    }
};

struct Foo
{
    int test()
    {
        return -1;
    }

    // this causes the brace-enclosed initializer error message:
    static constexpr Bar<Foo> bar = Bar<Foo>(&Foo::test);

    // but this line does not:
    // static constexpr Bar<Foo> bar = Bar<Foo>(nullptr);

    // this line also causes the error message, unless you remove the
    // explict constructor in Bar.
    // static constexpr Bar<Foo> bar = {&Foo::test};
};

constexpr Bar<Foo> Foo::bar;

// the line below does not cause any problems, either:
// static constexpr Bar<Foo> bar = Bar<Foo>(&Foo::test);

int main(void)
{
    Foo f;
    return (f.*(Foo::bar.h_))();
}

And here is gcc -v, again

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.9.1-16ubuntu6'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.1 (Ubuntu 4.9.1-16ubuntu6)

On Tue, Apr 7, 2015 at 7:35 PM, rbmj <rbmj@xxxxxxxxxxx> wrote:
> On 07-Apr-15 17:51, Bobby Moretti wrote:
>>
>>
>> Using compiler flags  -std=3Dc++11 -Wall -pedantic, this code fails to
>> compile for me using gcc 4.9.1:
>>
>
> Could this be a regression?  gcc 4.8.2 accepts this code, and works as
> expected.
>



-- 
Bobby Moretti
bobmoretti@xxxxxxxxx




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux