Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1349113

Re: Q: why didn't GCC warn about this uninitialized variable?

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: Q: why didn't GCC warn about this uninitialized variable?
Date 2016-03-03 13:50 +0100
Message-ID <r8ARz-7b8-7@gated-at.bofh.it> (permalink)
References (3 earlier) <r8f0K-89o-17@gated-at.bofh.it> <r8f0K-89o-15@gated-at.bofh.it> <r8Aoy-6Zk-9@gated-at.bofh.it> <r8AHV-77v-25@gated-at.bofh.it> <r8ARz-7b8-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 2016-03-03 at 13:43 +0100, Ingo Molnar wrote:
>  it would be absolutely fantastic if one of these solutions existed on GCC:> 
> 
>  - emit a warning if a structure is passed around uninitialized. A new GCC
>    __attribute__((struct_fully_initialized)) could be used to annotate extern
>    function arguments which fully initialize input arguments.
> 
>    (I'd personally migrate both tools/perf and kernel side code to use it, module
>     by module.)
> 
>  - or memset() to zero all on-stack structures that GCC cannot prove are
>    initialized fully.
> 
> The first solution takes extra work on the source level, the latter takes extra 
> runtime profiling to find where the extra memset()s matter to performance. Any of 
> these would be fantastic tools for C robustness and security.

Maybe memset any alignment padding between automatic variables too.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] perf tests: initialize sa.sa_flags Colin King <colin.king@canonical.com> - 2016-03-02 14:00 +0100
  Re: [PATCH] perf tests: initialize sa.sa_flags Peter Zijlstra <peterz@infradead.org> - 2016-03-02 14:00 +0100
    Re: [PATCH] perf tests: initialize sa.sa_flags Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 14:10 +0100
      Re: [PATCH] perf tests: initialize sa.sa_flags Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 14:30 +0100
        Q: why didn't GCC warn about this uninitialized variable? (was: Re:  [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 13:20 +0100
          Re: Q: why didn't GCC warn about this uninitialized variable? Colin Ian King <colin.king@canonical.com> - 2016-03-03 13:30 +0100
          Re: Q: why didn't GCC warn about this uninitialized variable? Måns Rullgård <mans@mansr.com> - 2016-03-03 13:40 +0100
            Re: Q: why didn't GCC warn about this uninitialized variable? Joe Perches <joe@perches.com> - 2016-03-03 13:50 +0100
            Re: Q: why didn't GCC warn about this uninitialized variable? Ingo Molnar <mingo@kernel.org> - 2016-03-03 13:50 +0100
          Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Jakub Jelinek <jakub@redhat.com> - 2016-03-03 14:00 +0100
            Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 14:30 +0100
              Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 14:50 +0100
                Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Jakub Jelinek <jakub@redhat.com> - 2016-03-03 15:20 +0100
                Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 15:50 +0100
                Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 16:00 +0100
                Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 16:10 +0100
              Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Jakub Jelinek <jakub@redhat.com> - 2016-03-03 14:50 +0100
                Re: Q: why didn't GCC warn about this uninitialized variable? (was:  Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar <mingo@kernel.org> - 2016-03-03 15:10 +0100
      Re: [PATCH] perf tests: initialize sa.sa_flags Peter Zijlstra <peterz@infradead.org> - 2016-03-02 14:30 +0100
  Re: [PATCH] perf tests: initialize sa.sa_flags Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 14:10 +0100

csiph-web