Why does this snippet using uniform initialization compile with g++4.6 but not g++4.7?

前端 未结 4 1790
孤独总比滥情好
孤独总比滥情好 2021-02-04 23:44

Note that derived uses C++11 uniform initialization syntax to call the base class constructor.

class base
{
    protected:
        base()
        {}
};
         


        
4条回答
  •  臣服心动
    2021-02-05 00:25

    compiling this with icpc ( intel compiler tested with version 11.1 -> 12.1) gives:

    -bash-3.2$ icpc -std=c++0x test.c 
    test.c(15): error: expected a declaration
              {}
              ^
    
    test.c(12): error: expected a "("
                  : base{} // <-- Note the c++11 curly brace syntax
                        ^
    
    compilation aborted for test.c (code 2)
    

    edit: but then again, c++11 is not fully implemented yet in icpc either http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler/

    same as with g++ http://gcc.gnu.org/gcc-4.7/cxx0x_status.html

    which clearly states it's still experimental, so a bug is very likely.

提交回复
热议问题