GCC 6.3 stack increased when using c++ exception compare to 4.9
Hi,
We try to upgrade our gcc 4.9 to gcc 6.3 and we observed that the stack usage is increased compare to 4.9 Here a small code that represent the problem.
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <stdexcept>
class TContractException: public std::logic_error
{
public:
TContractExcep
{
}
~TContractExce
{
}
};
class PostconditionEx
{
public:
PostconditionE
{
}
};
int main(int argc, char* argv[])
{
(void) argv;
try
{
if(argc == 4) throw "My exception";
if(argc == 5) throw PostconditionEx
}
catch(
{
printf("exception %s\n", e.what());
}
catch(...)
{
printf(
}
}
This is trivial code to show the problem. Compiling this code with 4.9 the first few asm line show that the stack reservation is 36 bytes
:../src/main.cpp **** int main(int argc, char* argv[])
35:..
490 .loc 2 35 0
491 .cfi_startproc
492 .cfi_personality 0,__gxx_
493 .cfi_lsda 0,.LLSDA785
494 @ args = 0, pretend = 0, frame = 32
495 @ frame_needed = 1, uses_anonymous_args = 0
496 0000 F0B5 push {r4, r5, r6, r7, lr}
497 .save {r4, r5, r6, r7, lr}
498 .cfi_def_cfa_offset 20
499 .cfi_offset 4, -20
500 .cfi_offset 5, -16
501 .cfi_offset 6, -12
502 .cfi_offset 7, -8
503 .cfi_offset 14, -4
504 .pad #36
505 0002 89B0 sub sp, sp, #36 <------
506 .cfi_def_cfa_offset 56
507 .setfp r7, sp, #0
508 0004 00AF add r7, sp, #0
509 .cfi_def_
510 0006 7860 str r0, [r7, #4]
511 0008 3960 str r1, [r7]
512 .LBB7:
But if i compile the same program with gcc 6.3 I got this asm lines
34:../src/main.cpp **** int main(int argc, char* argv[])
35:..
421 .loc 2 35 0
422 .cfi_startproc
423 .cfi_personality 0,__gxx_
424 .cfi_lsda 0,.LLSDA893
425 @ args = 0, pretend = 0, frame = 72
426 @ frame_needed = 1, uses_anonymous_args = 0
427 0000 F0B5 push {r4, r5, r6, r7, lr}
428 .save {r4, r5, r6, r7, lr}
429 .cfi_def_cfa_offset 20
430 .cfi_offset 4, -20
431 .cfi_offset 5, -16
432 .cfi_offset 6, -12
433 .cfi_offset 7, -8
434 .cfi_offset 14, -4
435 .pad #76
436 0002 93B0 sub sp, sp, #76 <---------------- More bytes allocated ????
437 .cfi_def_cfa_offset 96
438 .setfp r7, sp, #0
439 0004 00AF add r7, sp, #0
440 .cfi_def_
441 0006 7860 str r0, [r7, #4]
442 0008 3960 str r1, [r7]
I would like to have an explanation about this. If we have more exception type, the problem is worst.
regards
Jonathan
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Jonathan Dumaresq for more information if necessary.