public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* About initialization of automatic variables
@ 2023-04-18  3:51 naoki ueda
  2023-04-18  7:06 ` Andreas Schwab
  2023-04-18  8:26 ` Jonathan Wakely
  0 siblings, 2 replies; 5+ messages in thread
From: naoki ueda @ 2023-04-18  3:51 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

The attached code says "int a = 100;", but it should normally be
initialized with an "undefined value", but in the case of gcc-10, it is
initialized with "0". Isn't this a bug in gcc-10?

[-- Attachment #2: list1.c --]
[-- Type: text/x-csrc, Size: 574 bytes --]

#include <stdio.h>

int main(void)
{
    int n;

    for (n = 1;n <= 5;n++) {
        switch (n)
        {   int a = 100;
            static int b = 200;
            a = 111;
            b = 222;
        case 1:
            ++a; ++b;
            printf("case1: a = %d b = %d\n", a, b);
            break;
        case 3:
            ++a; ++b;
            printf("case3: a = %d b = %d\n", a, b);
        }
    }
    for (n = 1;n <= 3;n++) {
        int c = 300;
        static int d = 400;
        ++c; ++d;
        printf("for: c = %d d = %d\n", c, d);
    }
    return 0;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: About initialization of automatic variables
  2023-04-18  3:51 About initialization of automatic variables naoki ueda
@ 2023-04-18  7:06 ` Andreas Schwab
  2023-04-18  8:21   ` naoki ueda
  2023-04-18  8:26 ` Jonathan Wakely
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2023-04-18  7:06 UTC (permalink / raw)
  To: naoki ueda via Gcc-bugs; +Cc: naoki ueda

On Apr 18 2023, naoki ueda via Gcc-bugs wrote:

> The attached code says "int a = 100;", but it should normally be
> initialized with an "undefined value", but in the case of gcc-10, it is
> initialized with "0". Isn't this a bug in gcc-10?

0 is just one instance of "undefined value".

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: About initialization of automatic variables
  2023-04-18  7:06 ` Andreas Schwab
@ 2023-04-18  8:21   ` naoki ueda
  0 siblings, 0 replies; 5+ messages in thread
From: naoki ueda @ 2023-04-18  8:21 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: naoki ueda via Gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

Ok, thanks!

2023年4月18日(火) 16:06 Andreas Schwab <schwab@linux-m68k.org>:

> On Apr 18 2023, naoki ueda via Gcc-bugs wrote:
>
> > The attached code says "int a = 100;", but it should normally be
> > initialized with an "undefined value", but in the case of gcc-10, it is
> > initialized with "0". Isn't this a bug in gcc-10?
>
> 0 is just one instance of "undefined value".
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: About initialization of automatic variables
  2023-04-18  3:51 About initialization of automatic variables naoki ueda
  2023-04-18  7:06 ` Andreas Schwab
@ 2023-04-18  8:26 ` Jonathan Wakely
  2023-04-18  9:10   ` naoki ueda
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2023-04-18  8:26 UTC (permalink / raw)
  To: tantan19tanuki; +Cc: gcc-bugs

The gcc-bugs@gcc.gnu.org list is for automated email from our Bugzilla
database, please don't use it to report bugs or to ask questions about
how GCC works.

For questions about using GCC send email to gcc-help@gcc.gnu.org and
to report bugs please use bugzilla: https://gcc.gnu.org/bugs/

Thanks!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: About initialization of automatic variables
  2023-04-18  8:26 ` Jonathan Wakely
@ 2023-04-18  9:10   ` naoki ueda
  0 siblings, 0 replies; 5+ messages in thread
From: naoki ueda @ 2023-04-18  9:10 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Ok, I see.

2023年4月18日(火) 17:27 Jonathan Wakely <jwakely@redhat.com>:

> The gcc-bugs@gcc.gnu.org list is for automated email from our Bugzilla
> database, please don't use it to report bugs or to ask questions about
> how GCC works.
>
> For questions about using GCC send email to gcc-help@gcc.gnu.org and
> to report bugs please use bugzilla: https://gcc.gnu.org/bugs/
>
> Thanks!
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-18  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18  3:51 About initialization of automatic variables naoki ueda
2023-04-18  7:06 ` Andreas Schwab
2023-04-18  8:21   ` naoki ueda
2023-04-18  8:26 ` Jonathan Wakely
2023-04-18  9:10   ` naoki ueda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).