Update of gcc to 4.8.1

Just submit a solution and notice the change. Now codechef online judge updated to gcc 4.8.1 whereas previously it was 4.3.2.

Notice just one change.

  1. Its taking 0.6 MB of extra memory.

If anybody knows more about the features of this updated version. Feel free to share.

2 Likes

Wow that’s great! Codechef has upgraded gcc to latest version :smiley:

But the major reason for upgrading gcc has not been fulfilled. The support for C++11 in “not enabled”.


To enable C++11 (previously C++0x), the appropriate flag need to be passed -

g++ -std=c++0x prog.cpp

I made two submissions containing important C++11 features, but they are giving compilation error-

Here is AC submission in gcc 4.3.2 for NUMFACT

I wanted to try range-based for loop, and auto, so I made this submission in gcc 4.8.1. But it is giving following compilation error-

prog.cpp: In function ‘int main()’:
prog.cpp:72:14: warning: ‘auto’
changes meaning in C++11; please
remove it [-Wc++0x-compat] for (auto
&it : m) ^ prog.cpp:72:20: error: ISO
C++ forbids declaration of ‘it’ with
no type [-fpermissive] for (auto &it :
m) ^ prog.cpp:72:25: error:
range-based ‘for’ loops are not
allowed in C++98 mode for (auto &it :
m) ^ prog.cpp:74:24: error: request
for member ‘second’ in ‘it’, which is
of non-class type ‘int’ ans *=
(it.second + 1); ^

The difference-

C++98 (gcc 4.3.2)

    map<int, int> m;
    for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
    {
        ans *= (it->second + 1);
    }

C++11 (gcc 4.8.1)

    map<int, int> m;
    for (auto &it : m)
    {
        ans *= (it.second + 1);
    }

Another feature I tried - unique_ptr, by submitting to TEST. But again compilation error.


Endnote

@admin - please add flag --std=c++0x or even better --std=c++11 to compilation with gcc 4.8.1

1 Like

@vinayak_garg: We have another language option for C++11 which uses the flag option for gcc. You should submit your code under that language.

@admin: Thanks :slight_smile: I submitted my codes under C++11 and they got accepted.

I’ve been waiting for C++11 for so long, finally…! Big thanks to the Codechef team :wink: And yet, thanks to bring this up!

1 Like