[Bug sanitizer/64996] New: UBsan check optimized out by -O

2015-02-10 Thread sami.liedes at iki dot fi
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64996

Bug ID: 64996
   Summary: UBsan check optimized out by -O
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sami.liedes at iki dot fi
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

Consider this program:

#include limits.h
int main() {
int i=INT_MIN;
i--;
}

When compiled with -fsanitize=undefined -O0, ub is correctly detected:

$ gcc -fsanitize=undefined ub.c -o ub  ./ub
ub.c:4:10: runtime error: signed integer overflow: -2147483648 + -1 cannot be
represented in type 'int'

When compiled with -O, the entire check is optimized out, even if the program
still clearly exhibits ub:

$ gcc -fsanitize=undefined ub.c -o ub -O  ./ub
$ gcc -fsanitize=undefined ub.c -o ub.s -O -S
$ cat ub.s
.file   ub.c
.text
.globl  main
.type   main, @function
main:
.LFB0:
.cfi_startproc
rep ret
.cfi_endproc
.LFE0:
.size   main, .-main
.ident  GCC: (Debian 4.9.2-10) 4.9.2
.section.note.GNU-stack,,@progbits
$


[Bug c++/59404] New: declaration shadowing template parameter wrongly accepted

2013-12-05 Thread sami.liedes at iki dot fi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59404

Bug ID: 59404
   Summary: declaration shadowing template parameter wrongly
accepted
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sami.liedes at iki dot fi

Hi,

This code compiles with gcc -std=c++11 (but is rejected by clang++):

-
template typename T
struct A {
templatetypename T2
void f() {
typedef int T;
}
};

void g() {
Aint a;
a.fint();
}
-

However if the third line (templatetypename T2) is removed, GCC correctly
rejects the code because typedef int T shadows the template parameter T.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.8.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.2-7'
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Debian 4.8.2-7)