public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105180] New: K&R style definition does not evaluate array size
@ 2022-04-06 14:33 gcc at emil dot codes
  2022-04-09  6:33 ` [Bug c/105180] " egallager at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gcc at emil dot codes @ 2022-04-06 14:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105180

            Bug ID: 105180
           Summary: K&R style definition does not evaluate array size
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at emil dot codes
  Target Milestone: ---

GCC doesn't evaluates the size of an array when declared as a parameter in K&R
style declaration.


Example program:

    #include <stdio.h>

    int crime(s, c)
        char *s;
        char c[static printf("%s\n", s)];
    {
        return 0;
    }

    int accomplice(s) char *s;
    {
        return crime(s, s);
    }

    int main(void)
    {
        return accomplice("Hello");
    }

This should print "Hello\n". When using an ANSI definition, it does, but in
K&R-style, nothing is printed, `printf` isn't evaluated at all.

According to godbolt's compiler explorer, it is a regression which appeared
after GCC 4.6.4 and before or in GCC 4.7.1
It works correctly in clang but not in modern GCC.

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

end of thread, other threads:[~2023-07-07 10:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 14:33 [Bug c/105180] New: K&R style definition does not evaluate array size gcc at emil dot codes
2022-04-09  6:33 ` [Bug c/105180] " egallager at gcc dot gnu.org
2022-04-21 15:18 ` [Bug c/105180] [9/10/11/12 Regression] " jsm28 at gcc dot gnu.org
2022-05-27  9:47 ` [Bug c/105180] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:48 ` jakub at gcc dot gnu.org
2022-11-15  6:38 ` pinskia at gcc dot gnu.org
2022-11-15  6:48 ` pinskia at gcc dot gnu.org
2022-11-15  6:52 ` pinskia at gcc dot gnu.org
2023-01-11 16:48 ` jakub at gcc dot gnu.org
2023-01-13  9:36 ` jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug c/105180] [11/12/13/14 " rguenth at gcc dot gnu.org

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).