u5n's blog

By u5n, 3 years ago, In English

runnable example

If you run the following in custom invocation, you will get a COMPILATION_ERROR.

#include<iostream>
inline int arr[12000000];
int main(){
    std::cout << &(arr[0]);
}

/*
Invocation failed [COMPILATION_ERROR]
Can't compile file:
Compiled file is too large [50581889 bytes], but maximal allowed size is 33554432 bytes [CompileRequest {id='program.cpp', description='', file='program.cpp', resources='', type='cpp.gcc11-64-winlibs-g++20'}].
=====
Used: 0 ms, 0 KB
*/

The size of compiled file (50581889) increased by array size (12000000).

online compiler result

According to compile command in https://mirror.codeforces.com/blog/entry/96040,

https://godbolt.org/z/hzfe8qxjv vs https://godbolt.org/z/de3jjEK57

seems no difference, and both of their binary files use around 2.5MB, whereas initialize use {0,1} costs 50MB, that's why this topic is different from the previous.

I also test in my Debian os, and the compiled file size is very small and doesn't increase by array size(12000000).

how did this influence my submission

Another related minimal CE example

#include<iostream>

struct test{
    inline static int arr[12000000];
};

int main(){
    std::cout << &(test::arr[0]);
}

My first submission wants to preallocate spaces when new a tree node. So I use inline static data members without an out-of-class definition, I don't understand how this can increase compiled file size.

my question

Why will the inline global variable result a "Compiled file is too large" error?

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it