public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94912] New: Non-consistent behaviour of VLAs compared to C
@ 2020-05-02  1:12 gabravier at gmail dot com
  2020-05-02 21:46 ` [Bug c++/94912] Non-consistent behaviour of VLAs in C++ mode " msebor at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: gabravier at gmail dot com @ 2020-05-02  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94912
           Summary: Non-consistent behaviour of VLAs compared to C
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#include <stdbool.h>
#include <stdio.h>

bool f(int n)
{
    typedef int A[n];
    ++n;
    A a;
    int b[n];
    n -= 2;
    typedef int C[n];
    C c;

    return (sizeof(a) < sizeof(b)) && (sizeof(a) > sizeof(c));
}

int main()
{
        printf("%d", (int)f(10));
}

If compiled as C, this program will print 1. If compiled as C++, this program
will print 0. The C++ frontend seems to fail to take into account that the
`typedef`'s results are calculated at runtime based on the current value of
`n`.

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

* [Bug c++/94912] Non-consistent behaviour of VLAs in C++ mode compared to C
  2020-05-02  1:12 [Bug c++/94912] New: Non-consistent behaviour of VLAs compared to C gabravier at gmail dot com
@ 2020-05-02 21:46 ` msebor at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-05-02 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I think this is the same bug as reported in pr68531.

*** This bug has been marked as a duplicate of bug 68531 ***

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

end of thread, other threads:[~2020-05-02 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02  1:12 [Bug c++/94912] New: Non-consistent behaviour of VLAs compared to C gabravier at gmail dot com
2020-05-02 21:46 ` [Bug c++/94912] Non-consistent behaviour of VLAs in C++ mode " msebor 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).