This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64666] New: gcc wrongly accepts assignment in constant expression


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

            Bug ID: 64666
           Summary: gcc wrongly accepts assignment in constant expression
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com

Given source code 

void f()
{
    int i = 5, j;

    int a[ j = i];
}

Recent trunk code says

$ ~/gcc/results/bin/g++ -g -O2 -Wall -Wextra -c  jan19g.cc
jan19g.cc: In function âvoid f()â:
jan19g.cc:6:6: warning: unused variable âaâ [-Wunused-variable]
  int a[ j = i];
      ^
$ 

Here is clang doing something different


$ ~/llvm/results/bin/clang++ -g -O2 -Wall -c  jan19g.cc
jan19g.cc:6:11: error: expected ']'
        int a[ j = i];
                 ^
jan19g.cc:6:7: note: to match this '['
        int a[ j = i];
             ^
1 error generated.
$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]