cgccintermediate-language

debug low level gcc intermediate code representations


In connection with this question I have another question.

I managed to reproduce it and I do not copy paste the code here again, as you can find the code. I paste only the output of compilation on my computer.

% gcc -std=c11 -O3 -g -Wall -Wextra -Werror -USUPPRESS_BUG  -c  msg_gcc.c
msg_gcc.c: In function 'function_under_test':
msg_gcc.c:30:9: error: 'strncpy' output may be truncated copying 128 bytes from a string of length 128 [-Werror=stringop-truncation]
         strncpy(name, name_in_queue, SERVERNAME_LEN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
-root-@ @...| test | stub
% gcc --version
gcc (GCC) 8.2.1 20181127
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-root-@ @...| test | stub
% cat /proc/version
Linux version 5.0.7-arch1-1-ARCH (builduser@heftig-20167) (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Apr 8 10:37:08 UTC 2019
-root-@ @...| test | stub

I wish I would understand in which stage the compiler detects this kind of library issue. I know that the code is transformed in lots of intermediate languages, like generic, gimple, ssa, rtl, combinators, etc, etc but I do not know in which of these representations the code is checked for issues like this one from this compilation command.

If I want to debug the intermediate representations and discover the presence of this issue what parameters should I pass gcc such that it stops the generation of intermediate languages as close as possible before this warning to be generated ?


Solution

  • Your error/warning seems to be originating from here. If I understand correctly, this is from the SSA form generation phase.

    Also this question might provide useful hints on how to dump different intermediate representations for gcc. I know how to do it for clang, but your issue seems be to specific to gcc.