Valid code which gets CE without details

Правка en1, от semiexp, 2016-05-07 18:15:20

During our team training on Codeforces Gym, we noticed that a code which can easily be compiled in our computer gets CE (even the details for CE wasn't shown) on the Codeforces judge system.

After the training, I've investigated the cause of CE and finally I've found that the following code produces CE if compiled with GNU C++11:

#include <algorithm>
#include <cstdio>
using namespace std;
struct segtree
{
	pair<int, int> data[1<<20];
};
segtree S;
int main()
{
	return 0;
}

You may write codes like this when you implement Segment Trees or like.

This code can easily be compiled with GCC 4.8.4. However, if it is compiled with GCC 5.3.0, the compilation didn't finish at all. I suppose that compiling it takes much time with GCC 5.1.0 (which is used in Codeforces), too and very long compilation time caused CE without any detail.

Apparently, this problem is a bug of GCC; related problem is reported to GCC Bugzilla. The bug fix has already been released, so I expect that this problem will be fixed in GCC of later version. But currently we can't avoid this problem if we use GNU C++11.

My suggestions are: - Avoid using GNU C++11. The code above could be compiled with other compilers (such as GNU C++). - Avoid using array of std::pair in structs or classes, e.g. define a new struct instead of using std::pair for array members in structs. One of the cause of this problem is that std::pair has a constexpr default constructor.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский semiexp 2016-05-07 18:15:20 1577 Initial revision (published)