From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25964 invoked by alias); 22 Mar 2015 16:43:28 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25905 invoked by uid 48); 22 Mar 2015 16:43:24 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65168] diagnostic: missing: reference cannot be bound to dereferenced null pointer Date: Sun, 22 Mar 2015 17:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02273.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65168 --- Comment #3 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- I got confused by Clang's message. The problem is not the pointer or NULL. = The problem is converting the address of a reference to bool: int fii(int *p) { int &r=3D*p; return !&r; } This is trivial to implement in GCC: manuel@gcc14:~$ ~/test1/221557M/build/gcc/cc1plus -Waddress ~/pr65168.cc /home/manuel/pr65168.cc:3:12: warning: address of reference =E2=80=98r=E2= =80=99 may be assumed to always convert to true because in C++ a reference cannot be bound to dereferenced null pointer [-Waddress] return !&r; ^ Does this patch work in your real-world code? Index: c-common.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- c-common.c (revision 221557) +++ c-common.c (working copy) @@ -4776,11 +4776,18 @@ c_common_truthvalue_conversion (location } CASE_CONVERT: { tree totype =3D TREE_TYPE (expr); - tree fromtype =3D TREE_TYPE (TREE_OPERAND (expr, 0)); + tree op0 =3D TREE_OPERAND (expr, 0); + tree fromtype =3D TREE_TYPE (op0); + + if (TREE_CODE (fromtype) =3D=3D REFERENCE_TYPE + && POINTER_TYPE_P (totype) && DECL_P (op0)) + warning_at (location, OPT_Waddress, + "address of reference %qD may be assumed to always convert to true" + " because in C++ a reference cannot be bound to dereferenced null pointer", op0); /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE, since that affects how `default_conversion' will behave. */ if (TREE_CODE (totype) =3D=3D REFERENCE_TYPE || TREE_CODE (fromtype) =3D=3D REFERENCE_TYPE) >>From gcc-bugs-return-481130-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Mar 22 16:45:20 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 57269 invoked by alias); 22 Mar 2015 16:45:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 57232 invoked by uid 48); 22 Mar 2015 16:45:16 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65168] diagnostic: missing: reference cannot be bound to dereferenced null pointer Date: Sun, 22 Mar 2015 17:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02274.txt.bz2 Content-length: 198 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65168 --- Comment #4 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- Or even: int fii(int p) { int &r=3Dp; return !&r; } >>From gcc-bugs-return-481131-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Mar 22 16:52:18 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 66103 invoked by alias); 22 Mar 2015 16:52:18 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 66068 invoked by uid 48); 22 Mar 2015 16:52:12 -0000 From: "nheghathivhistha at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/65516] New: lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 Date: Sun, 22 Mar 2015 17:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nheghathivhistha at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02275.txt.bz2 Content-length: 11202 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65516 Bug ID: 65516 Summary: lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: nheghathivhistha at gmail dot com Spidermonkey compilation ICEs lto1, trunk revision 221558. /var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/work/mozjs-24.2.0/js/src/_virtualenv/bin/python ./config/expandlibs_exec.py --depend .deps/.//libmozjs-24.so.pp --target libmozjs-24.so --uselist -- x86_64-pc-linux-gnu-g++ -Wall -Wpointer-arith -Woverloaded-virtual -Werror=return-type -Wtype-limits -Wempty-body -Werror=conversion-null -Wsign-compare -Wno-invalid-offsetof -Wcast-align -flto=4 -fuse-linker-plugin -O2 -g -pipe -march=core2 -mtune=core2 -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -pthread -pipe -DNDEBUG -DTRIMMED -fno-omit-frame-pointer -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -fPIC -shared -Wl,-z,defs -Wl,-h,libmozjs-24.so -o libmozjs-24.so bignum-dtoa.o bignum.o cached-powers.o diy-fp.o double-conversion.o fast-dtoa.o fixed-dtoa.o strtod.o HashFunctions.o Poison.o SHA1.o Decimal.o ArgumentsObject.o BytecodeCompiler.o BytecodeEmitter.o CharacterEncoding.o DateTime.o Debugger.o Eval.o ExecutableAllocator.o FoldConstants.o ForkJoin.o GlobalObject.o Interpreter.o Intl.o Iteration.o LifoAlloc.o MapObject.o Marking.o Memory.o Module.o Monitor.o NameFunctions.o Nursery.o Object.o ObjectImpl.o PageBlock.o ParallelArray.o ParseMaps.o ParseNode.o Parser.o Probes.o Profilers.o PropertyKey.o RegExp.o RegExpObject.o RegExpStatics.o RootMarking.o SPSProfiler.o ScopeObject.o SelfHosting.o Shape.o Stack.o Statistics.o StoreBuffer.o String.o StringBuffer.o TestingFunctions.o ThreadPool.o TokenStream.o Unicode.o Verifier.o Xdr.o YarrCanonicalizeUCS2.o YarrInterpreter.o YarrPattern.o YarrSyntaxChecker.o Zone.o jsalloc.o jsanalyze.o jsapi.o jsarray.o jsatom.o jsbool.o jsclone.o jscntxt.o jscompartment.o jscrashreport.o jsdate.o jsdbgapi.o jsdtoa.o jsexn.o jsfriendapi.o jsfun.o jsgc.o jsinfer.o jsiter.o jsmath.o jsmemorymetrics.o jsnativestack.o jsnum.o jsobj.o json.o jsonparser.o jsopcode.o jsperf.o jsprf.o jspropertytree.o jsproxy.o jsreflect.o jsscript.o jsstr.o jstypedarray.o jsutil.o jswatchpoint.o jsweakmap.o jsworkers.o jswrapper.o prmjtime.o sharkctl.o ExecutableAllocatorPosix.o OSAllocatorPosix.o pm_linux.o -lpthread -Wl,-flto -fuse-linker-plugin -Wl,--as-needed -Wl,-O2 -Wl,--sort-common -Wl,--hash-style=gnu -O2 -g -pipe -march=core2 -mtune=core2 -Wl,--build-id -Wl,-rpath-link,./dist/bin -Wl,-rpath-link,/usr/lib -lplds4 -lplc4 -lnspr4 -lpthread -ldl -Wl,-version-script,symverscript -licui18n -licuuc -licudata -ldl -lm -lz -ldl Executing: x86_64-pc-linux-gnu-g++ -Wall -Wpointer-arith -Woverloaded-virtual -Werror=return-type -Wtype-limits -Wempty-body -Werror=conversion-null -Wsign-compare -Wno-invalid-offsetof -Wcast-align -flto=4 -fuse-linker-plugin -O2 -g -pipe -march=core2 -mtune=core2 -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -pthread -pipe -DNDEBUG -DTRIMMED -fno-omit-frame-pointer -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -fPIC -shared -Wl,-z,defs -Wl,-h,libmozjs-24.so -o libmozjs-24.so /var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/work/mozjs-24.2.0/js/src/tmpA0RSz7.list -lpthread -Wl,-flto -fuse-linker-plugin -Wl,--as-needed -Wl,-O2 -Wl,--sort-common -Wl,--hash-style=gnu -O2 -g -pipe -march=core2 -mtune=core2 -Wl,--build-id -Wl,-rpath-link,./dist/bin -Wl,-rpath-link,/usr/lib -lplds4 -lplc4 -lnspr4 -lpthread -ldl -Wl,-version-script,symverscript -licui18n -licuuc -licudata -ldl -lm -lz -ldl /var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/work/mozjs-24.2.0/js/src/tmpA0RSz7.list: INPUT("bignum-dtoa.o") INPUT("bignum.o") INPUT("cached-powers.o") INPUT("diy-fp.o") INPUT("double-conversion.o") INPUT("fast-dtoa.o") INPUT("fixed-dtoa.o") INPUT("strtod.o") INPUT("HashFunctions.o") INPUT("Poison.o") INPUT("SHA1.o") INPUT("Decimal.o") INPUT("ArgumentsObject.o") INPUT("BytecodeCompiler.o") INPUT("BytecodeEmitter.o") INPUT("CharacterEncoding.o") INPUT("DateTime.o") INPUT("Debugger.o") INPUT("Eval.o") INPUT("ExecutableAllocator.o") INPUT("FoldConstants.o") INPUT("ForkJoin.o") INPUT("GlobalObject.o") INPUT("Interpreter.o") INPUT("Intl.o") INPUT("Iteration.o") INPUT("LifoAlloc.o") INPUT("MapObject.o") INPUT("Marking.o") INPUT("Memory.o") INPUT("Module.o") INPUT("Monitor.o") INPUT("NameFunctions.o") INPUT("Nursery.o") INPUT("Object.o") INPUT("ObjectImpl.o") INPUT("PageBlock.o") INPUT("ParallelArray.o") INPUT("ParseMaps.o") INPUT("ParseNode.o") INPUT("Parser.o") INPUT("Probes.o") INPUT("Profilers.o") INPUT("PropertyKey.o") INPUT("RegExp.o") INPUT("RegExpObject.o") INPUT("RegExpStatics.o") INPUT("RootMarking.o") INPUT("SPSProfiler.o") INPUT("ScopeObject.o") INPUT("SelfHosting.o") INPUT("Shape.o") INPUT("Stack.o") INPUT("Statistics.o") INPUT("StoreBuffer.o") INPUT("String.o") INPUT("StringBuffer.o") INPUT("TestingFunctions.o") INPUT("ThreadPool.o") INPUT("TokenStream.o") INPUT("Unicode.o") INPUT("Verifier.o") INPUT("Xdr.o") INPUT("YarrCanonicalizeUCS2.o") INPUT("YarrInterpreter.o") INPUT("YarrPattern.o") INPUT("YarrSyntaxChecker.o") INPUT("Zone.o") INPUT("jsalloc.o") INPUT("jsanalyze.o") INPUT("jsapi.o") INPUT("jsarray.o") INPUT("jsatom.o") INPUT("jsbool.o") INPUT("jsclone.o") INPUT("jscntxt.o") INPUT("jscompartment.o") INPUT("jscrashreport.o") INPUT("jsdate.o") INPUT("jsdbgapi.o") INPUT("jsdtoa.o") INPUT("jsexn.o") INPUT("jsfriendapi.o") INPUT("jsfun.o") INPUT("jsgc.o") INPUT("jsinfer.o") INPUT("jsiter.o") INPUT("jsmath.o") INPUT("jsmemorymetrics.o") INPUT("jsnativestack.o") INPUT("jsnum.o") INPUT("jsobj.o") INPUT("json.o") INPUT("jsonparser.o") INPUT("jsopcode.o") INPUT("jsperf.o") INPUT("jsprf.o") INPUT("jspropertytree.o") INPUT("jsproxy.o") INPUT("jsreflect.o") INPUT("jsscript.o") INPUT("jsstr.o") INPUT("jstypedarray.o") INPUT("jsutil.o") INPUT("jswatchpoint.o") INPUT("jsweakmap.o") INPUT("jsworkers.o") INPUT("jswrapper.o") INPUT("prmjtime.o") INPUT("sharkctl.o") INPUT("ExecutableAllocatorPosix.o") INPUT("OSAllocatorPosix.o") INPUT("pm_linux.o") lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 Please submit a full bug report, with preprocessed source if appropriate. Please submit a full bug report, with preprocessed source if appropriate. Please submit a full bug report, with preprocessed source if appropriate. Please submit a full bug report, with preprocessed source if appropriate. See for instructions. See for instructions. See for instructions. See for instructions. make[2]: *** [/var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/temp/ccoWodiH.ltrans2.ltrans.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[2]: *** [/var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/temp/ccoWodiH.ltrans3.ltrans.o] Error 1 make[2]: *** [/var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/temp/ccoWodiH.ltrans0.ltrans.o] Error 1 make[2]: *** [/var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/temp/ccoWodiH.ltrans1.ltrans.o] Error 1 lto-wrapper: fatal error: make returned 2 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/4.10.0-pre20150320/../../../../x86_64-pc-linux-gnu/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status config/rules.mk:1023: recipe for target 'libmozjs-24.so' failed make[1]: *** [libmozjs-24.so] Error 1 make[1]: Leaving directory '/var/tmp/portage/dev-lang/spidermonkey-24.2.0-r2/work/mozjs-24.2.0/js/src' config/rules.mk:678: recipe for target 'default' failed make: *** [default] Error 2 * ERROR: dev-lang/spidermonkey-24.2.0-r2::gentoo failed (compile phase): * emake failed gcc -v Using built-in specs. COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.10.0-pre20150320/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.10.0-pre20150320/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.10.0_pre20150320/work/gcc-4.10.0-20150320/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.10.0-pre20150320 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.10.0-pre20150320/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.10.0-pre20150320 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.10.0-pre20150320/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.10.0-pre20150320/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.10.0-pre20150320/include/g++-v4 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.10.0-pre20150320/python --enable-languages=c,c++,fortran,ada --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.10.0_pre20150320' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --enable-lto --with-cloog --disable-isl-version-check --enable-libsanitizer Thread model: posix gcc version 4.10.0-pre20150320 20150321 (experimental) [trunk revision 221558] (Gentoo 4.10.0_pre20150320) Two or three object files are needed to reproduce it, I will attach ii files. x86_64-pc-linux-gnu-g++ -fuse-linker-plugin -O2 -g -pipe -march=core2 -mtune=core2 -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -pthread -pipe -DNDEBUG -DTRIMMED -fno-omit-frame-pointer -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -fPIC -Wl,-z,defs -Wl,-h,libmozjs-24.so -o libmozjs-24.so Debugger.o GlobalObject.o Marking.o Shape.o -r -nostdliblto1: internal compiler error: in get_odr_type, at ipa-devirt.c:1809 Please submit a full bug report, with preprocessed source if appropriate. See for instructions. lto-wrapper: fatal error: /usr/x86_64-pc-linux-gnu/gcc-bin/4.10.0-pre20150320/x86_64-pc-linux-gnu-g++ returned 1 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/4.10.0-pre20150320/../../../../x86_64-pc-linux-gnu/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status