[ubsan] Instrument __builtin_unreachable

2013-07-13 Thread Marek Polacek
I had to pluck some code out of c-family/c-ubsan.c (otherwise we couldn't call ubsan_* routines from builtins.c), I've put the code into ubsan.c. Commited to ubsan branch. Comments? (I think I'm going to solve the ubsan testsuite now.) 2013-07-14 Marek Polacek pola...@redhat.com

Re: [ubsan] Instrument __builtin_unreachable

2013-07-13 Thread Marek Polacek
On Sun, Jul 14, 2013 at 07:39:38AM +0200, Marek Polacek wrote: This patch implements sanitizing of the __builtin_unreachable call. A call to __builtin_unreachable only emits BARRIER, if we actually get to it, the behavior is undefined. So, we just replace the call with a call to the ubsan

Re: [ubsan] Instrument __builtin_unreachable

2013-07-14 Thread Marek Polacek
On Sun, Jul 14, 2013 at 03:44:40PM +0200, Jakub Jelinek wrote: On Sun, Jul 14, 2013 at 07:39:38AM +0200, Marek Polacek wrote: This patch implements sanitizing of the __builtin_unreachable call. A call to __builtin_unreachable only emits BARRIER, if we actually get to it, the behavior

Re: Minor Cygwin patches

2013-07-14 Thread Marek Polacek
On Mon, Jul 15, 2013 at 09:15:27AM +0800, JonY wrote: On 7/15/2013 06:02, Kai Tietz wrote: 2013/7/13 JonY 10wa...@gmail.com: On 7/10/2013 20:43, JonY wrote: Hi, Attached are some minor patches, comments? Kai, ping? Please sent each patch as separate mail, and please add

[ubsan] Don't always use NORETURN

2013-07-15 Thread Marek Polacek
Some libubsan functions aren't really noreturn, so don't mark them as such. This prevents failures with -O1+, since we don't generate any code after calling noreturn routines, thus segfault when we actually get there. Applying to ubsan branch. 2013-07-15 Marek Polacek pola...@redhat.com

[ubsan] Add testsuite

2013-07-15 Thread Marek Polacek
testsuite they don't check much more. Maybe we should test also stuff like ++a (v * x) etc.? Tested with make check RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp' Any comments before I put this on ubsan branch? 2013-07-15 Marek Polacek pola...@redhat.com * gcc.c

[ubsan] Add more testing

2013-07-22 Thread Marek Polacek
This adds more testing to the ubsan testsuite. It still doesn't test everything, but it's better than nothing and I've already found one bug (already fixed). Tested with RUNTESTFLAGS='--target_board=unix\{-m32,-m64\}. Commited to ubsan branch. 2013-07-22 Marek Polacek pola...@redhat.com

[PATCH] Don't include gimple.h twice

2013-07-22 Thread Marek Polacek
I don't think there's a reason to include gimple.h twice... Regtested/bootstrapped on x86_64-linux, will commit as obvious soon. 2013-07-22 Marek Polacek pola...@redhat.com * gimplify.c: Don't include gimple.h twice. --- gcc/gimplify.c.mp 2013-07-22 15:29:17.202468003 +0200 +++ gcc

Re: [Patch, PR 57811] Wasted work in find_reloads()

2013-07-22 Thread Marek Polacek
On Mon, Jul 22, 2013 at 11:39:38AM -0500, pcha...@cs.wisc.edu wrote: Hi, The problem appears in revision 201034 in version 4.9. I attached one-line patches that fixes it. I also reported this problem at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57811 Bootstrap and regression-tested on

Re: [ubsan] Add libcall arguments

2013-07-22 Thread Marek Polacek
On Mon, Jul 22, 2013 at 10:09:00AM -0400, Jason Merrill wrote: On 07/19/2013 02:45 PM, Marek Polacek wrote: /* This type represents an entry in the hash table. */ struct ubsan_typedesc { + /* This represents the type of a variable. */ tree type; + + /* This is the VAR_DECL

Re: Typo in GCC Internals documentation.

2013-07-23 Thread Marek Polacek
On Tue, Jul 23, 2013 at 11:32:39AM +0200, Nicklas Bo Jensen wrote: Hi, Found a typo in the GCC Internals documentation in one of the code examples in 16.18.2 RTL to RTL Peephole Optimizers. Thanks, looks good, though the ChangeLog entry is missing, so something like: 2013-07-23 Nicklas Bo

[ubsan] Move ubsan CL entries to separate CLs

2013-07-25 Thread Marek Polacek
gcc/testsuite/ChangeLog.ubsan diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7eb40f1..32f46ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,120 +1,3 @@ -2013-07-24 Marek Polacek pola...@redhat.com - - * ubsan.c (struct ubsan_typedesc): Improve comment. - -2013-07-21 Marek Polacek

Request to merge Undefined Behavior Sanitizer in

2013-07-25 Thread Marek Polacek
Hi! I'd like to announce first version of the Undefined Behavior Sanitizer, a tool I've spent this June/July hacking on. It is an undefined behavior detector for the C family FEs and works by creating a COMPOUND_EXPR around original expression, for slightly more information see my slides about

Re: [PATCH] Fix missing deps for tree-sra.o

2013-07-25 Thread Marek Polacek
On Thu, Jul 25, 2013 at 01:21:27PM -0400, David Malcolm wrote: Successfully bootstrapped on x86_64-unknown-linux-gnu OK for trunk? commit 4d7b6e5cf8e7f2613f516c9b9fe1f888b1193f8d Author: David Malcolm dmalc...@redhat.com Date: Tue Jul 23 16:11:14 2013 -0400 Add missing deps to

Re: Request to merge Undefined Behavior Sanitizer in

2013-07-25 Thread Marek Polacek
On Thu, Jul 25, 2013 at 04:13:29PM -0400, Jason Merrill wrote: On 07/25/2013 11:32 AM, Marek Polacek wrote: + vec_alloc (v, 3); + tree ctor = build_constructor (dtype, v); You might use build_constructor_va instead of managing a vector directly. Thanks, will give it a try. Otherwise

Re: Request to merge Undefined Behavior Sanitizer in

2013-07-26 Thread Marek Polacek
On Thu, Jul 25, 2013 at 10:33:46PM -0700, Andrew Pinski wrote: What does it mean by unsigned-integer-overflow? Unsigned integers never overflow. Or maybe I misread the documentation here. Well, clang can sanitize even when unsigned int wraps. But this feature seems doubtful, I don't think I

Re: Request to merge Undefined Behavior Sanitizer in

2013-07-29 Thread Marek Polacek
On Thu, Jul 25, 2013 at 10:50:14PM -0600, Jeff Law wrote: On 07/25/2013 04:40 PM, Joseph S. Myers wrote: On Thu, 25 Jul 2013, Marek Polacek wrote: So far it sanitizes division-by-zeros, shifts and __builtin_unreachable calls. This is of course far from being complete; I intend to write

[ubsan] Add -static-libubsan

2013-07-30 Thread Marek Polacek
+1,8 @@ +2013-07-29 Marek Polacek pola...@redhat.com + + * common.opt (static-libubsan): New option. + * doc/invoke.texi: Document -static-libubsan. + 2013-07-24 Marek Polacek pola...@redhat.com * ubsan.c (struct ubsan_typedesc): Improve comment. diff --git a/gcc

[ubsan] Don't try to sanitize shifts outside of functions

2013-07-30 Thread Marek Polacek
Marek Polacek pola...@redhat.com + + * c-typeck.c (build_binary_op): Sanitize only when + current_function_decl is not zero. + 2013-07-21 Marek Polacek pola...@redhat.com * c-typeck.c (build_binary_op): Call c_fully_fold on both diff --git a/gcc/c/c-typeck.c b/gcc/c/c

[ubsan] Add bootstrap-ubsan.mk

2013-07-30 Thread Marek Polacek
/null +++ b/config/ChangeLog.ubsan @@ -0,0 +1,3 @@ +2013-07-30 Marek Polacek pola...@redhat.com + + * bootstrap-ubsan.mk: New. diff --git a/config/bootstrap-ubsan.mk b/config/bootstrap-ubsan.mk new file mode 100644 index 000..10543f6 --- /dev/null +++ b/config/bootstrap-ubsan.mk @@ -0,0

[ubsan] Use build_constructor_va where possible

2013-07-30 Thread Marek Polacek
/ChangeLog.ubsan +++ b/gcc/ChangeLog.ubsan @@ -1,3 +1,9 @@ +2013-07-30 Marek Polacek pola...@redhat.com + + * ubsan.c (ubsan_source_location): Use build_constructor_va + instead of build_constructor. + (ubsan_type_descriptor): Likewise. + 2013-07-29 Marek Polacek pola

[ubsan] Rename obsolete variable

2013-07-30 Thread Marek Polacek
/gcc/ChangeLog.ubsan @@ -1,5 +1,10 @@ 2013-07-30 Marek Polacek pola...@redhat.com + * config/rs6000/rs6000.h (FRAME_GROWS_DOWNWARD): Use flag_sanitize + instead of flag_asan. + +2013-07-30 Marek Polacek pola...@redhat.com + * ubsan.c (ubsan_source_location): Use

Re: [ubsan] Add bootstrap-ubsan.mk

2013-07-30 Thread Marek Polacek
On Tue, Jul 30, 2013 at 04:34:14PM +0200, Marek Polacek wrote: This adds the bootstrap-ubsan.mk file so that --with-build-config=bootstrap-ubsan be possible. I doesn't work yet, though :(. One of the reasons is that we use -Werror and e.g. on the following testcase static int x; void foo

[ubsan] Instrument expr only when doing shift or division

2013-07-31 Thread Marek Polacek
-unknown-linux-gnu, applying to ubsan branch. diff --git a/gcc/c/ChangeLog.ubsan b/gcc/c/ChangeLog.ubsan index 11d167f..f41ae90 100644 --- a/gcc/c/ChangeLog.ubsan +++ b/gcc/c/ChangeLog.ubsan @@ -1,3 +1,8 @@ +2013-07-31 Marek Polacek pola...@redhat.com + + * c-typeck.c (build_binary_op): Sanitize

Re: Request to merge Undefined Behavior Sanitizer in

2013-07-31 Thread Marek Polacek
On Thu, Jul 25, 2013 at 10:40:22PM +, Joseph S. Myers wrote: What happens if you bootstrap with this enabled - do whatever failures appear look like genuine bugs? Running the testsuite with a compiler built with this option? Running the testsuite with this option used when compiling

[ubsan] Improve documentation of -fsanitize=undefined

2013-07-31 Thread Marek Polacek
This patch hopefully improves the documentation of the option in question. Applying to ubsan branch. diff --git a/gcc/ChangeLog.ubsan b/gcc/ChangeLog.ubsan index ac584ff..d7932c5 100644 --- a/gcc/ChangeLog.ubsan +++ b/gcc/ChangeLog.ubsan @@ -1,3 +1,7 @@ +2013-07-31 Marek Polacek pola

Re: Request to merge Undefined Behavior Sanitizer in

2013-07-31 Thread Marek Polacek
On Thu, Jul 25, 2013 at 10:43:30PM +, Joseph S. Myers wrote: On Thu, 25 Jul 2013, Marek Polacek wrote: +@item -fsanitize=undefined +Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector +Various computations will be instrumented to detect +undefined behavior, e.g

[ubsan] Add missing ubsan tests in g++.dg/dg.exp

2013-07-31 Thread Marek Polacek
/ChangeLog.ubsan @@ -1,3 +1,7 @@ +2013-07-31 Marek Polacek pola...@redhat.com + + * g++.dg/dg.exp: Add missing ubsan tests. + 2013-07-30 Marek Polacek pola...@redhat.com * c-c++-common/ubsan/const-expr.c: New test. diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-07-31 Thread Marek Polacek
On Thu, Jul 25, 2013 at 04:13:29PM -0400, Jason Merrill wrote: Otherwise, looks fine. If nobody else has comments, go ahead and check it in next week. I had to make a few changes since, particularly: - [ubsan] Add -static-libubsan http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01467.html -

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-01 Thread Marek Polacek
On Wed, Jul 31, 2013 at 02:52:39PM -0400, Jason Merrill wrote: On 07/31/2013 01:33 PM, Marek Polacek wrote: There are still at least two issues though, which is why bootstrap with -fsanitize=undefined fails: http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01480.html This looks like a serious

Re: New branch: ubsan

2013-08-05 Thread Marek Polacek
On Sun, Aug 04, 2013 at 06:55:13PM +0200, Gerald Pfeifer wrote: On Fri, 5 Jul 2013, Marek Polacek wrote: I've created a new branch, called ubsan for work being done for Undefined Behavior Sanitizer. Mind documenting this in http://gcc.gnu.org/svn.html? Let me know if you need help

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-05 Thread Marek Polacek
-value warning), but that didn't seem to be necessary... Does that look up to snuff to you? Thanks, 2013-08-05 Marek Polacek pola...@redhat.com * c-ubsan.c (ubsan_instrument_shift): Properly evaluate SAVE_EXPR even in the C89 mode. * gcc.dg/ubsan/save-expr-1.c: New test

[ubsan] Properly create const char type

2013-08-05 Thread Marek Polacek
I was creating the const char type in a wrong way. I should've used build_qualified_type, otherwise we'd ICE in the C++ FE later on due to mismatched TYPE_CANONICALs... Tested x86_64-pc-linux-gnu, applying to ubsan branch. 2013-08-05 Marek Polacek pola...@redhat.com * ubsan.c

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-06 Thread Marek Polacek
On Wed, Jul 31, 2013 at 02:52:39PM -0400, Jason Merrill wrote: http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01536.html Here, the C++ compiler is wrong to fold away the division by zero, but given that bug the folding ought to also eliminate the call to the sanitize function. Seems like you

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Tue, Aug 06, 2013 at 07:07:27PM -0400, Jason Merrill wrote: I think, what we could do, is to tweak verify_constant like this: + /* This is to handle e.g. the goofy 'case 0 * (1 / 0)' case. */ + if (flag_sanitize SANITIZE_UNDEFINED + TREE_CODE (t) == CALL_EXPR +

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Tue, Aug 06, 2013 at 05:24:08PM -0400, Jason Merrill wrote: On 08/05/2013 07:24 AM, Marek Polacek wrote: On Sat, Aug 03, 2013 at 12:24:32PM -0400, Jason Merrill wrote: Where are the SAVE_EXPRs coming from? It doesn't seem to me that x needs to be wrapped in a SAVE_EXPR at all in this case

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Wed, Aug 07, 2013 at 10:24:59AM -0400, Jason Merrill wrote: On 08/07/2013 06:06 AM, Marek Polacek wrote: I might've misunderstood what you mean. If we drop the hunk above, then we'll call error (%q+E is not a constant expression, t); so, we'll print is not a constant expression

Re: RFA: implement C11 _Generic

2013-08-09 Thread Marek Polacek
On Tue, Jul 23, 2013 at 01:55:19AM +, Joseph S. Myers wrote: I have now revised this patch from a year ago in line with my understanding of how _Generic ought to handle the various special cases (selector undergoes lvalue-to-rvalue conversion, and decay of functions and arrays to pointers,

[PATCH] Fix PR57980

2013-08-09 Thread Marek Polacek
create even the VECTOR_TYPE constant (and, it can create even REAL_TYPE/COMPLEX_TYPE), as suggested by Marc. Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.8? 2013-08-09 Marek Polacek pola...@redhat.com Marc Glisse marc.gli...@inria.fr PR tree-optimization/57980

Re: [PATCH] Fix PR57980

2013-08-12 Thread Marek Polacek
On Fri, Aug 09, 2013 at 08:40:00PM +0200, Richard Biener wrote: Marek Polacek pola...@redhat.com wrote: In this PR the problem was that when dealing with the gimple assign in the tailcall optimization, we, when the rhs operand is of a vector type, need to create -1 also of a vector type

Re: [PATCH] Update MAINTAINERS file

2013-08-12 Thread Marek Polacek
On Mon, Aug 12, 2013 at 12:53:56PM -0700, Caroline Tice wrote: Ping? Is this one of those I can commit without waiting for approval? Yes. Marek

Re: [PATCH] Fix PR57980

2013-08-13 Thread Marek Polacek
On Tue, Aug 13, 2013 at 12:24:59PM +0200, Jakub Jelinek wrote: On Mon, Aug 12, 2013 at 10:56:44AM +0200, Marek Polacek wrote: On Fri, Aug 09, 2013 at 08:40:00PM +0200, Richard Biener wrote: Marek Polacek pola...@redhat.com wrote: In this PR the problem was that when dealing

Re: [PATCH] Fix PR57980

2013-08-13 Thread Marek Polacek
, adjusted with the following; will commit as obvious. 2013-08-13 Marek Polacek pola...@redhat.com * gcc.dg/pr57980.c: Use vector of two elements, not just one. --- gcc/testsuite/gcc.dg/pr57980.c.mp 2013-08-13 14:03:22.104617686 +0200 +++ gcc/testsuite/gcc.dg/pr57980.c 2013-08-13 14

[PATCH] Quash undefined behavior in ipa-inline-analysis.c

2013-08-13 Thread Marek Polacek
for trunk? 2013-08-13 Marek Polacek pola...@redhat.com * ipa-inline-analysis.c (add_clause): Avoid undefined behavior when shifting integer. --- gcc/ipa-inline-analysis.c.mp2013-08-13 14:07:48.632662047 +0200 +++ gcc/ipa-inline-analysis.c 2013-08-13 14:08:16.728770973

[ubsan] Add -lpthread to POSTSTAGE1_LDFLAGS

2013-08-14 Thread Marek Polacek
When doing bootstrap with ubsan, some files require libpthread to be linked. This patch adds -lpthread into POSTSTAGE1_LDFLAGS for the bootstrap-ubsan. Applying to the ubsan branch. 2013-08-14 Marek Polacek pola...@redhat.com * bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Add -lpthread

[ubsan] Fix assert in c-ubsan.c

2013-08-14 Thread Marek Polacek
We ICEd on the following testcase because even though the underlying types were the same, theirs TREE_TYPEs were not. We can use TYPE_MAIN_VARIANT to see through the typedefs which confused us. Tested x86_64-pc-linux-gnu, applying to the ubsan branch. 2013-08-14 Marek Polacek pola

Re: Fix potential uninitialized variable error

2013-08-14 Thread Marek Polacek
On Wed, Aug 14, 2013 at 11:12:27AM -0700, Xinliang David Li wrote: Index: ChangeLog === --- ChangeLog (revision 201732) +++ ChangeLog (working copy) @@ -1,4 +1,8 @@ 2013-08-14 Xinliang David Li davi...@google.com +

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Marek Polacek
Ping. On Wed, Aug 07, 2013 at 06:12:58PM +0200, Marek Polacek wrote: On Wed, Aug 07, 2013 at 10:24:59AM -0400, Jason Merrill wrote: On 08/07/2013 06:06 AM, Marek Polacek wrote: I might've misunderstood what you mean. If we drop the hunk above, then we'll call error (%q+E

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Marek Polacek
On Wed, Aug 07, 2013 at 04:58:03PM +0200, Marek Polacek wrote: I actually don't know what I prefer more, but if you like this version more, I'll go with it. Maybe this is better because we don't have to create SAVE_EXPR and also we avoid one fold_build call. Thanks, Not creating

Request to merge Undefined Behavior Sanitizer in (take 3)

2013-08-15 Thread Marek Polacek
I've fixed a few unpleasant bugs; mainly the bug that introduced various uninitialized variable warnings was bothersome. Now it is possible to do bootstrap with -fsanitize=undefined, even though there are some comparison failures at the end. v3: - Fix Wuninitialized warnings because of

Re: GDB hooks for debugging GCC

2013-08-20 Thread Marek Polacek
On Mon, Aug 19, 2013 at 03:45:57PM -0600, Jeff Law wrote: In this specific instance I was referring to getting meaningful data out of gdb when I do something like p bb or p e for a block and edge respectively. Printing the pointer is useful, but printing information about the actual

Re: Request to merge Undefined Behavior Sanitizer in (take 3)

2013-08-20 Thread Marek Polacek
On Thu, Aug 15, 2013 at 05:08:48PM +0200, Marek Polacek wrote: One patch is not in yet, but that isn't anything important: http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00376.html I've now commited this patch: diff --git a/gcc/ChangeLog.ubsan b/gcc/ChangeLog.ubsan index 9040b68..695522e

Re: Request to merge Undefined Behavior Sanitizer in (take 3)

2013-08-22 Thread Marek Polacek
Ping. On Thu, Aug 15, 2013 at 05:08:48PM +0200, Marek Polacek wrote: I've fixed a few unpleasant bugs; mainly the bug that introduced various uninitialized variable warnings was bothersome. Now it is possible to do bootstrap with -fsanitize=undefined, even though there are some comparison

Re: Request to merge Undefined Behavior Sanitizer in (take 3)

2013-08-22 Thread Marek Polacek
On Thu, Aug 22, 2013 at 07:51:07PM +0200, Marek Polacek wrote: Ping. I'm withdrawing the ping for now. I'll have to deal with some bootstrap comparison failures first (ugh!). Marek

[ubsan] Fix bootstrap comparison

2013-08-23 Thread Marek Polacek
-linux, applying to the ubsan branch. 2013-08-23 Marek Polacek pola...@redhat.com * ubsan.c (ubsan_typedesc_hasher::hash): Hash the TYPE_UID of the type. (ubsan_type_descriptor): Get TYPE_MAIN_VARIANT before initializing the type descriptor. --- gcc/ubsan.c.mp

Re: [ubsan] Fix bootstrap comparison

2013-08-23 Thread Marek Polacek
On Fri, Aug 23, 2013 at 02:44:49PM +0200, Jakub Jelinek wrote: Why not just return TYPE_UID (data-type); ? Wasn't aware it's enough. Anyway, once you change the hash table uses into pointer_map, this will all go away. Right. Marek

[ubsan] Introduce pointer_sized_int_node

2013-08-26 Thread Marek Polacek
I noticed I forgot to apply this old patch, already acked by Jason. It introduces new pointer_sized_int_node, thus we can get rid of uptr_type function in ubsan, and it allows us to do some clean-up in asan.c, too. Tested x86_64-linux, applying to ubsan branch. 2013-08-26 Marek Polacek pola

Re: [PATCH, doc] Document -fsanitize=signed-integer-overflow

2013-12-05 Thread Marek Polacek
Ping. The implementation has been commited. On Thu, Nov 28, 2013 at 01:32:24PM +0100, Marek Polacek wrote: As promised, this patch on top of this patch by Tobias: http://gcc.gnu.org/ml/gcc-patches/2013-11/msg03082.html adds the documentation for -fsanitize=signed-integer-overflow. Ok

[PATCH] Fix up passing long long in ubsan with -m32 (PR sanitizer/59333)

2013-12-05 Thread Marek Polacek
for it. Bootstrapped, ran ubsan testsuite on x86_64-unknown-linux-gnu. Ok for trunk? 2013-12-05 Marek Polacek pola...@redhat.com PR sanitizer/59333 * ubsan.c: Include rtl.h. (ubsan_encode_value): Add new parameter. If expanding, assign a stack slot for DECL_RTL of the temporary

Re: Make C11 _Alignof return least not greatest alignment for a type (PR c/52023)

2013-12-05 Thread Marek Polacek
-common.c:5007:9: error: unused variable ‘field’ [-Werror=unused-variable] tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, The following should fix it. 2013-12-05 Marek Polacek pola...@redhat.com c-family/ * c-common.c (c_sizeof_or_alignof_type): Move a declaration

Re: [PATCH] Fix up passing long long in ubsan with -m32 (PR sanitizer/59333)

2013-12-05 Thread Marek Polacek
On Thu, Dec 05, 2013 at 12:37:27PM +0100, Jakub Jelinek wrote: On Thu, Dec 05, 2013 at 12:26:25PM +0100, Marek Polacek wrote: --- gcc/ubsan.h.mp 2013-12-05 11:25:18.979469651 +0100 +++ gcc/ubsan.h 2013-12-05 11:25:28.958507098 +0100 @@ -41,7 +41,7 @@ extern tree

Re: [PATCH] Fix up passing long long in ubsan with -m32 (PR sanitizer/59333)

2013-12-05 Thread Marek Polacek
On Thu, Dec 05, 2013 at 04:44:29PM +0100, Jakub Jelinek wrote: On Thu, Dec 05, 2013 at 04:31:20PM +0100, Marek Polacek wrote: + } + t = build_fold_addr_expr (var); + return build2 (COMPOUND_EXPR, TREE_TYPE (t), tem, t); I would expect you want to use

Re: [PATCH] Fix up passing long long in ubsan with -m32 (PR sanitizer/59333)

2013-12-05 Thread Marek Polacek
On Thu, Dec 05, 2013 at 06:22:02PM +0100, Jakub Jelinek wrote: As a follow-up, please see if all the dg-skip-if -flto ubsan markings can be removed now. Unfortunately, not yet. With -flto, we fail with cclAoIBG.o:(.text+0x14): undefined reference to `.Lubsan_data0.2616'^M collect2: error: ld

[PATCH] Don't segv in vtable verification with ubsan (PR sanitizer/59415)

2013-12-09 Thread Marek Polacek
We ICEd on the following testcase with -fsanitize=null and vtable verification on, because gimple_call_fn returns NULL for UBSAN_* internal functions. Fixed by checking the result for NULL before accessing its TREE_CODE. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2013-12-09 Marek

Re: [PATCH] Don't segv in vtable verification with ubsan (PR sanitizer/59415)

2013-12-09 Thread Marek Polacek
On Mon, Dec 09, 2013 at 03:29:38PM +0100, Jakub Jelinek wrote: On Mon, Dec 09, 2013 at 03:23:30PM +0100, Marek Polacek wrote: We ICEd on the following testcase with -fsanitize=null and vtable verification on, because gimple_call_fn returns NULL for UBSAN_* internal functions. Fixed

[PATCH] Deal with promotions for internal functions (PR sanitizer/59399)

2013-12-09 Thread Marek Polacek
-gnu and x86_64-unknown-linux-gnu. Ok for trunk? [1] http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00609.html 2013-12-09 Marek Polacek pola...@redhat.com PR sanitizer/59399 * expr.c (expand_expr_real_1): Remove assert dealing with internal calls and turn

[PATCH] Another segv in vtv with ubsan (PR sanitizer/59437)

2013-12-09 Thread Marek Polacek
-12-09 Marek Polacek pola...@redhat.com PR sanitizer/59437 * vtable-verify.c (var_is_used_for_virtual_call_p): Check the return value of gimple_call_fn. Use is_gimple_call/is_gimple_assign instead of gimple_code. testsuite/ * g++.dg/ubsan/pr59437.C: New

[PATCH] Use correct optab when expanding a binop (PR sanitizer/59503)

2013-12-13 Thread Marek Polacek
I noticed this bug a while ago on ppc64 and now I reproduced it even on x86_64 with -m32. The problem was that we were using add_optab even when dealing with MINUS_EXPR; we should use sub_optab instead. Regtested on x86_64-linux (with both -m32/-m64), ok for trunk? 2013-12-14 Marek Polacek

[PATCH] Add more testing to ubsan #1

2013-12-14 Thread Marek Polacek
This adds two sanity tests for signed-integer-overflow sanitization. One variant uses asms to prevent ccp/... from optimizing away the computations. Nothing in these tests should fail. Regtested on x86_64-unknown-linux-gnu and powerpc64-unknown-linux-gnu, ok for trunk? 2013-12-14 Marek Polacek

[PATCH] Add more testing to ubsan #2

2013-12-14 Thread Marek Polacek
This adds more testing of unary -. Regtested on x86_64-linux with -m32/-m64, ok for trunk? 2013-12-14 Marek Polacek pola...@redhat.com testsuite/ * c-c++-common/ubsan/overflow-negate-1.c: Add more testing. Don't require int128 target. * c-c++-common/ubsan/overflow

[PATCH] Add __int128 test to ubsan

2013-12-17 Thread Marek Polacek
Regtested on x86_64-linux with -m32/-m64. Ok? 2013-12-17 Marek Polacek pola...@redhat.com testsuite/ * c-c++-common/ubsan/overflow-int128.c: New test. --- gcc/testsuite/c-c++-common/ubsan/overflow-int128.c.mp 2013-12-17 16:54:28.123468111 +0100 +++ gcc/testsuite/c-c++-common

Re: [PATCH] Add __int128 test to ubsan

2013-12-17 Thread Marek Polacek
On Tue, Dec 17, 2013 at 06:50:24PM +0100, Jakub Jelinek wrote: Isn't this undefined behavior in C? I mean, shouldn't you shift up (unsigned __int128) 1 and only cast to (__int128) at the end? Oh my, how could I. Yeah, (__int128) 1 127 is UB. Fixed below, ok now? 2013-12-17 Marek Polacek

[PATCH] Avoid uninitialized warning in i386.c

2013-12-18 Thread Marek Polacek
Bootstrap with -fsanitize=undefined revealed that the alg variable may be used uninitialized. Or at least gcc thinks so. This patch initializes it to 0. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2013-12-18 Marek Polacek pola...@redhat.com * config/i386/i386.c

Re: [PATCH] Avoid uninitialized warning in i386.c

2013-12-18 Thread Marek Polacek
On Wed, Dec 18, 2013 at 02:45:12PM +0100, Jakub Jelinek wrote: On Wed, Dec 18, 2013 at 02:39:44PM +0100, Marek Polacek wrote: Bootstrap with -fsanitize=undefined revealed that the alg variable may be used uninitialized. Or at least gcc thinks so. This patch initializes it to 0

[C++ PATCH] Don't ICE on TYPE_BINFO (PR c++/59111)

2013-12-20 Thread Marek Polacek
We ICEd on invalid testcases with auto, because lookup_conversions got template_type_parm as a parameter and the TYPE_BINFO didn't like it. Fixed by checking for RECORD_OR_UNION_TYPE_P first. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2013-12-20 Marek Polacek pola...@redhat.com

[PATCH] Fix typo in docs

2014-01-03 Thread Marek Polacek
__builtin_{FILE,FUNCTION} had wrong return types, thus fixed. Tested by make html and links -g. Ok for trunk? 2014-01-03 Marek Polacek pola...@redhat.com PR other/59661 * doc/extend.texi: Fix the return value of __builtin_FUNCTION and __builtin_FILE. --- gcc/doc

[C PATCH] Don't pedwarn for C99/C11 enum bit-fields (PR c/57773)

2014-01-03 Thread Marek Polacek
Marek Polacek pola...@redhat.com PR c/57773 c/ * c-decl.c (check_bitfield_type_and_width): Warn for enum bit-fields only in ISO C. testsuite/ * gcc.dg/pr57773.c: New test. --- gcc/c/c-decl.c.mp 2014-01-03 13:50:37.041997222 +0100 +++ gcc/c/c-decl.c 2014-01-03

Re: [C PATCH] Don't pedwarn for C99/C11 enum bit-fields (PR c/57773)

2014-01-06 Thread Marek Polacek
, 2014-01-06 Marek Polacek pola...@redhat.com PR c/57773 * doc/implement-c.texi: Mention that other integer types are permitted as bit-field types in strictly conforming mode. c/ * c-decl.c (check_bitfield_type_and_width): Warn for implementation defined

[PATCH] Strip array types when getting the typename (PR sanitizer/59667)

2014-01-07 Thread Marek Polacek
In case we're dealing with (*)[N] types, we should strip the ARRAY_TYPEs prior to getting the type name. Otherwise we segv, since the DECL_NAME is NULL. Regtested on x86_64-linux, ok for trunk? 2014-01-07 Marek Polacek pola...@redhat.com PR sanitizer/59667 * ubsan.c

[PATCH] Don't segv in omp-low.c (PR middle-end/59669)

2014-01-08 Thread Marek Polacek
We can also get NULL for the default definition, so we need to handle that before calling has_zero_uses on it. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-01-08 Marek Polacek pola...@redhat.com PR middle-end/59669 * omp-low.c (simd_clone_adjust): Don't crash

Re: [PATCH] Don't segv in omp-low.c (PR middle-end/59669)

2014-01-08 Thread Marek Polacek
On Wed, Jan 08, 2014 at 04:14:06PM +0100, Jakub Jelinek wrote: On Wed, Jan 08, 2014 at 04:09:08PM +0100, Marek Polacek wrote: We can also get NULL for the default definition, so we need to handle that before calling has_zero_uses on it. Bootstrapped/regtested on x86_64-linux, ok

[C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-13 Thread Marek Polacek
/unions doesn't really make sense and this patch forbids that. Note that GCC permits a structure/union to have no members, but it's only an extension, in C11 it's undefined behavior. Regtested/bootstrapped on x86_64, ok for trunk? 2014-01-13 Marek Polacek pola...@redhat.com PR c/58346 c

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-13 Thread Marek Polacek
On Mon, Jan 13, 2014 at 05:32:26PM +0100, Marek Polacek wrote: This doesn't really fix the PR, but solves a related issue, where we have e.g. struct U {}; static struct U b[6]; int foo (struct U *p, struct U *q) { return q - p; } int main() { return foo (b[0], b[4

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-13 Thread Marek Polacek
On Mon, Jan 13, 2014 at 05:48:59PM +0100, Marek Polacek wrote: The patch will need some tweaking, I realized that e.g. for struct S { union {}; }; it doesn't do the right thing... Done in the patch below. CCing Jason for the C++ part. Does this look sane now? Regtested/bootstrapped on x86_64

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-15 Thread Marek Polacek
On Tue, Jan 14, 2014 at 06:52:00PM +0100, Florian Weimer wrote: On 01/13/2014 09:48 PM, Marek Polacek wrote: +bool +pointer_to_zero_sized_aggr_p (tree t) +{ + t = strip_pointer_operator (t); + if (RECORD_OR_UNION_TYPE_P (t) + TYPE_SIZE (t) + integer_zerop (TYPE_SIZE (t

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-15 Thread Marek Polacek
On Tue, Jan 14, 2014 at 09:42:37PM +, Joseph S. Myers wrote: On Mon, 13 Jan 2014, Marek Polacek wrote: +/* Return true if T is a pointer to a zero-sized struct/union. */ + +bool +pointer_to_zero_sized_aggr_p (tree t) +{ + t = strip_pointer_operator (t

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-15 Thread Marek Polacek
On Wed, Jan 15, 2014 at 11:35:40AM +0100, Jakub Jelinek wrote: On Wed, Jan 15, 2014 at 11:27:37AM +0100, Marek Polacek wrote: Perhaps, but I don't think we can do it easily. Consider int foo (int *p, int *q) { return p - q; } That is not a difference of pointers to zero sized

[PATCH] Don't ICE on invalid array types (PR middle-end/59827)

2014-01-15 Thread Marek Polacek
We ICE on the following (invalid) testcase, because the DECL_ARG_TYPE is error_mark_node and useless_type_conversion_p doesn't check that it operates on a type. Regtested/bootstrapped on x86_64-linux, ok for trunk/4.8/4.7? 2014-01-15 Marek Polacek pola...@redhat.com PR middle-end

Re: [PATCH] Diagnose pr54694

2014-01-15 Thread Marek Polacek
On Wed, Jan 15, 2014 at 01:43:18PM -0800, Richard Henderson wrote: On 01/15/2014 08:37 AM, H.J. Lu wrote: We should add a testcase to verify this. I included the following testcase with the commit. I couldn't find a way to test this properly generically, so I just went with the obvious

Re: [RFA][PATCH][PR middle-end/57904][P1 regression] Improve cleanups after copyprop

2014-01-15 Thread Marek Polacek
-ENOPATCH

Re: [PATCH] fix for PR 59825

2014-01-15 Thread Marek Polacek
On Wed, Jan 15, 2014 at 10:37:04PM +, Iyer, Balaji V wrote: +2014-01-15 Balaji V. Iyer balaji.v.i...@intel.com + + PR c/59825 + * c-array-notation.c (expand_array_notation_exprs): Added COMPOUND_EXPR + case. + Add --- a/gcc/c/c-array-notation.c +++

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-16 Thread Marek Polacek
On Thu, Jan 16, 2014 at 12:50:10PM +0100, Eric Botcazou wrote: +/* Return true if T is a pointer to a zero-sized struct/union. */ + +bool +pointer_to_zero_sized_aggr_p (tree t) +{ + t = strip_pointer_operator (t); + return ((RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) ==

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-16 Thread Marek Polacek
On Wed, Jan 15, 2014 at 09:23:06PM +, Joseph S. Myers wrote: On Wed, 15 Jan 2014, Marek Polacek wrote: +/* Return true if T is a pointer to a zero-sized struct/union. */ + +bool +pointer_to_zero_sized_aggr_p (tree t) +{ + t = strip_pointer_operator (t); + return

Re: [PATCH] _Cilk_for for C and C++

2014-01-17 Thread Marek Polacek
On Thu, Jan 16, 2014 at 01:18:59PM -0800, Aldy Hernandez wrote: I'm not a C++ expert, but my understanding was that in C++ you don't need a typedef to use the following structure by name (cilk_for_information). So you can just declare struct cilk_for_information {...} and instantiate it with

[PATCH] Don't fold zero-sized elements (PR c/58346)

2014-01-17 Thread Marek Polacek
This is the real fix for PR58346. I'd say the easiest solution is just not fold the zero-sized elements. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-01-17 Marek Polacek pola...@redhat.com PR c/58346 * gimple-fold.c (fold_array_ctor_reference): Don't fold

[C++ PATCH] Don't segv in cvt.c (PR c++/59838)

2014-01-17 Thread Marek Polacek
for trunk/4.8/4.7? 2014-01-17 Marek Polacek pola...@redhat.com PR c++/59838 cp/ * cvt.c (ocp_convert): Don't segfault on non-existing ENUM_UNDERLYING_TYPE. testsuite/ * g++.dg/diagnostic/pr59838.C: New test. --- gcc/cp/cvt.c.mp32014-01-17 12:01:20.926793491 +0100

[C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-21 Thread Marek Polacek
adjust one testcase and a header in libdecnumber. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2014-01-21 Marek Polacek pola...@redhat.com PR c/59871 c/ * c-typeck.c (build_compound_expr): Warn even for right-hand operand of comma expression

Re: [C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-21 Thread Marek Polacek
On Tue, Jan 21, 2014 at 09:18:17PM +0100, Marc Glisse wrote: On Tue, 21 Jan 2014, Marek Polacek wrote: --- gcc/libdecnumber/decNumberLocal.h.mp 2014-01-21 18:34:32.235540589 +0100 +++ gcc/libdecnumber/decNumberLocal.h2014-01-21 19:04:12.173243034 +0100 @@ -155,8 +155,10

Re: [C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-21 Thread Marek Polacek
On Tue, Jan 21, 2014 at 07:50:13PM +0100, Jakub Jelinek wrote: On Tue, Jan 21, 2014 at 07:38:10PM +0100, Marek Polacek wrote: --- gcc/gcc/c/c-typeck.c.mp 2014-01-21 11:59:33.221215248 +0100 +++ gcc/gcc/c/c-typeck.c2014-01-21 18:10:53.900279750 +0100 @@ -4757,6 +4757,18

Re: [C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-21 Thread Marek Polacek
On Tue, Jan 21, 2014 at 11:34:42PM +0100, Jakub Jelinek wrote: On Tue, Jan 21, 2014 at 11:30:58PM +0100, Marek Polacek wrote: I made another small change: in the second hunk, in emit_side_effect_warnings, I got rid of the while, since it seems to me we never get COMPOUND_EXPR

<    2   3   4   5   6   7   8   9   10   11   >