public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67584] New: Compilation is fine if an undeclared identifier is used in a for range-based loop, and lsh has the same name as rhs
@ 2015-09-15 10:01 tony at becrux dot com
  2015-09-15 10:16 ` [Bug c++/67584] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: tony at becrux dot com @ 2015-09-15 10:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67584
           Summary: Compilation is fine if an undeclared identifier is
                    used in a for range-based loop, and lsh has the same
                    name as rhs
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tony at becrux dot com
  Target Milestone: ---

GCC does not fail in compiling the following code:

#include <vector>

class A : public std::vector< int >
{
public:
  A(int x) : std::vector< int >(x) { }
};

int main(int, char **)
{
  for (A v : v)
  {

  }

  return 0;
}

"A" class has been declared just to "trick" the vector behavior (i.e. remove
the explicit constructor) and fool the compiler.

Command-line used for compilation:

g++ -v -save-temps -std=c++11 -Wall -Wextra -pedantic -o for_bug.exe
for_bug.cpp

No warning is generated.

I've tested 5.2 too, and older version of GCC (4.8 and 4.7 series), the result
is always the same (using an online compiler).

Clang and ICC behave correctly, i.e. compilation fails cause "v" is an
undeclared identifier (using an online compiler).

GCC version used for test is 5.1.0, MinGW-w64, Windows 7 64 bit. The produced
executable crashes during execution.

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-5.1.0/configure --host=i686-w64-mingw32
--build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32
--with-sysroot=/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32
--with-gxx-include-dir=/mingw32/i686-w64-mingw32/include/c++ --enable-shared
--enable-static --disable-multilib --enable-languages=c,c++,lto
--enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp
--enable-libatomic --enable-lto --enable-graphite --enable-checking=release
--enable-fully-dynamic-string --enable-version-specific-runtime-libs
--enable-sjlj-exceptions --disable-isl-version-check --disable-libstdcxx-pch
--disable-libstdcxx-debug --disable-bootstrap --disable-rpath
--disable-win32-registry --disable-nls --disable-werror --disable-symvers
--with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=i686 --with-libiconv
--with-system-zlib
--with-gmp=/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static
--with-mpfr=/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static
--with-mpc=/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static
--with-isl=/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static
--with-pkgversion='i686-win32-sjlj, Built by Antonio Di Monaco'
--with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe
-march=i686 -mtune=i686 -mthreads
-I/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32/opt/include
-I/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-zlib-static/include
-I/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static/include'
CXXFLAGS='-O2 -pipe -march=i686 -mtune=i686 -mthreads
-I/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32/opt/include
-I/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-zlib-static/include
-I/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static/include'
CPPFLAGS= LDFLAGS='-pipe
-L/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32/opt/lib
-L/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-zlib-static/lib
-L/home/Tony/mingw-gcc-5.1.0/prerequisites/i686-w64-mingw32-static/lib
-Wl,--large-address-aware'
Thread model: win32
gcc version 5.1.0 (i686-win32-sjlj, Built by Antonio Di Monaco) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-Wpedantic' '-o' 'for_bug.exe' '-shared-libgcc' '-mtune=i686' '-march=i686'

C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/cc1plus.exe
-E -quiet -v -iprefix
C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/
-U_REENTRANT for_bug.cpp -mtune=i686 -march=i686 -std=c++11 -Wall -Wextra
-Wpedantic -fpch-preprocess -o for_bug.ii
ignoring duplicate directory
"C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.1.0/include"
ignoring nonexistent directory
"C:/msys32/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32C:/msys32/mingw32/lib/gcc/i686-w64-mingw32/5.1.0/../../../../include"
ignoring duplicate directory
"C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.1.0/include-fixed"
ignoring duplicate directory
"C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory
"C:/msys32/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/include

C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/include-fixed

C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/include
 C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../i686-w64-mingw32/include/c++

C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../i686-w64-mingw32/include/c++/i686-w64-mingw32

C:/i686-510-win32-sjlj-rt_v4/lib/gcc/../../i686-w64-mingw32/include/c++/backward
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-Wpedantic' '-o' 'for_bug.exe' '-shared-libgcc' '-mtune=i686' '-march=i686'

C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/cc1plus.exe
-fpreprocessed for_bug.ii -quiet -dumpbase for_bug.cpp -mtune=i686 -march=i686
-auxbase for_bug -Wall -Wextra -Wpedantic -std=c++11 -version -o for_bug.s
GNU C++11 (i686-win32-sjlj, Built by Antonio Di Monaco) version 5.1.0
(i686-w64-mingw32)
        compiled by GNU C version 4.8.4, GMP version 6.0.0, MPFR version
3.1.2-p11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++11 (i686-win32-sjlj, Built by Antonio Di Monaco) version 5.1.0
(i686-w64-mingw32)
        compiled by GNU C version 4.8.4, GMP version 6.0.0, MPFR version
3.1.2-p11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: cd26162daf8c5b33311803309ba41a5d
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-Wpedantic' '-o' 'for_bug.exe' '-shared-libgcc' '-mtune=i686' '-march=i686'

C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/bin/as.exe
-v -o for_bug.o for_bug.s
GNU assembler version 2.25 (i686-w64-mingw32) using BFD version (GNU Binutils)
2.25
COMPILER_PATH=C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/;C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/lib/../lib/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../lib/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/lib/;C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-Wpedantic' '-o' 'for_bug.exe' '-shared-libgcc' '-mtune=i686' '-march=i686'

C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/collect2.exe
-plugin
C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/liblto_plugin-0.dll
-plugin-opt=C:/i686-510-win32-sjlj-rt_v4/bin/../libexec/gcc/i686-w64-mingw32/5.1.0/lto-wrapper.exe
-plugin-opt=-fresolution=for_bug.res -plugin-opt=-pass-through=-lmingw32
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex
-plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32
-plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32
-plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv
-plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname
-plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt
--sysroot=C:/msys32/home/Tony/mingw-gcc-5.1.0/i686-510-win32-sjlj-rt_v4/mingw32
-m i386pe -Bdynamic -o for_bug.exe
C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/lib/../lib/crt2.o
C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/crtbegin.o
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/lib/../lib
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../lib
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../../../i686-w64-mingw32/lib
-LC:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/../../..
for_bug.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt
-ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc
-lmoldname -lmingwex -lmsvcrt
C:/i686-510-win32-sjlj-rt_v4/bin/../lib/gcc/i686-w64-mingw32/5.1.0/crtend.o


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

* [Bug c++/67584] Compilation is fine if an undeclared identifier is used in a for range-based loop, and lsh has the same name as rhs
  2015-09-15 10:01 [Bug c++/67584] New: Compilation is fine if an undeclared identifier is used in a for range-based loop, and lsh has the same name as rhs tony at becrux dot com
@ 2015-09-15 10:16 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Probably another symptom of Bug 54430, just a particularly nasty variation of
it.

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


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

end of thread, other threads:[~2015-09-15 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15 10:01 [Bug c++/67584] New: Compilation is fine if an undeclared identifier is used in a for range-based loop, and lsh has the same name as rhs tony at becrux dot com
2015-09-15 10:16 ` [Bug c++/67584] " redi 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).