Mac g++ throws a compilation error with this code:
#include <iostream>
using namespace std;
int main(int argc, char ** argv) {
int * p = new int[5] {1,2,3};
return 0;
}
I tried an online compiler and it compiles and runs without errors.
Is there something wrong with mac compiler? Can I do something to change how it works or should I install another c++ compiler?
Edit:
The error:
test.cpp:6:25: error: expected ';' at end of declaration
int * p = new int[5] {1,2,3};
Compiler target and version:
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Compile command:
g++ test.cpp