[LLVMbugs] [Bug 12841] Invalid Name Redefinition Error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 15 22:22:39 PDT 2012


Douglas Gregor <dgregor at apple.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Douglas Gregor <dgregor at apple.com> 2012-05-16 00:22:39 CDT ---
Clang is correct to reject this code, per C++ [stmt.select]p3, which says that
a variable declared in a condition (that's the "bool varName = (a_argc == 1))")
cannot be redeclared in the outermost block of the substatement. The example in
the standard is nearly identical to yours:

if (int x = f()) {
  int x; // ill-formed, redeclaration of x
else {
  int x; // ill-formed, redeclaration of x

So, GCC is wrong to accept this code.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list