[Bug analyzer/96611] New: ICE in get_or_create_cluster

2020-08-14 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96611

Bug ID: 96611
   Summary: ICE in get_or_create_cluster
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

On GCC tip of master from 20200814.
While static analyzing the racket source (github.com/racket/racket), it fails
on (reduced):
struct {
  long a;
} * b;
void c();
int d() {
  c();
  c(>a);
  return 1;
}

with message:
~/racket/racket/src/bc/rktio# /gcc/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/cc1
-fpreprocessed rktio_sleep.i -quiet -dumpbase rktio_sleep.c -dumpbase-ext .c
-mtune=generic -march=x86-64 -g -O2 -Wall -version -Werror -Wfatal-errors
-fanalyzer -o rktio_sleep.s
GNU C17 (GCC) version 11.0.0 20200814 (experimental) (x86_64-pc-linux-gnu)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2,
MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C17 (GCC) version 11.0.0 20200814 (experimental) (x86_64-pc-linux-gnu)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2,
MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: bca87f5421b78e00047ba8f5a58d16b4
during IPA pass: analyzer
rktio_sleep.i: In function 'd':
rktio_sleep.i:7:3: internal compiler error: in get_or_create_cluster, at
analyzer/store.cc:1613
7 |   c(>a);
  |   ^~~~
0x735ea1 ana::store::get_or_create_cluster(ana::region const*)
../../gcc/gcc/analyzer/store.cc:1613
0x115ca10 ana::store::mark_as_escaped(ana::region const*)
../../gcc/gcc/analyzer/store.cc:1694
0x115237b ana::reachable_regions::mark_escaped_clusters()
../../gcc/gcc/analyzer/region-model-reachability.cc:218
0x113e3fc ana::region_model::handle_unrecognized_call(gcall const*,
ana::region_model_context*)
../../gcc/gcc/analyzer/region-model.cc:773
0x113e5bd ana::region_model::on_call_post(gcall const*, bool,
ana::region_model_context*)
../../gcc/gcc/analyzer/region-model.cc:707
0x111af7c ana::exploded_node::on_stmt(ana::exploded_graph&, ana::supernode
const*, gimple const*, ana::program_state*) const
../../gcc/gcc/analyzer/engine.cc:1105
0x111bd22 ana::exploded_graph::process_node(ana::exploded_node*)
../../gcc/gcc/analyzer/engine.cc:2526
0x111c69a ana::exploded_graph::process_worklist()
../../gcc/gcc/analyzer/engine.cc:2341
0x111e6bc ana::impl_run_checkers(ana::logger*)
../../gcc/gcc/analyzer/engine.cc:4107
0x111f8bd ana::run_checkers()
../../gcc/gcc/analyzer/engine.cc:4175
0x11142b8 execute
../../gcc/gcc/analyzer/analyzer-pass.cc:84
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

[Bug analyzer/94689] arrays of functions are not meaningful

2020-08-13 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94689

--- Comment #6 from pmatos at gcc dot gnu.org ---
Thanks - I will rerun the static analyzer on the codebase that previously
crashed the static analyzer and report back.

[Bug analyzer/94689] arrays of functions are not meaningful

2020-05-12 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94689

--- Comment #4 from pmatos at gcc dot gnu.org ---
Unfortunately a fix for this didn't make it into 10.1. We can still not analyze
racket source code due to this issue.

[Bug analyzer/94689] New: arrays of functions are not meaningful

2020-04-21 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94689

Bug ID: 94689
   Summary: arrays of functions are not meaningful
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

With head of git from today (2020.04.21), gcc with -fanalyzer return non-zero
exit code for

///
*a;
b;
c() { d((void (*)())a + b); }

///


using the command line:
gcc -O2 -g -fanalyzer  -Wall   -I./.. -I./../include -I./../../rktio
-I../../rktio -pthread -I/usr/lib64/libffi/include   -DUSE_SENORA_GC-c
foreign.i -o foreign.o

yet, if you remove the -fanalyzer flag it returns exit code 0.

[Bug analyzer/94688] New: ice caused by analyzer

2020-04-21 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94688

Bug ID: 94688
   Summary: ice caused by analyzer
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

While reducing a testcase for a separate bug I found an analyzer ice.

///
a, b;
c() { d((void (*)()) & a + b); }
/// 

Compiled with todays (2020.04.21) head:
  gcc -O2 -g -fanalyzer  -Wall   -I./.. -I./../include -I./../../rktio
-I../../rktio -pthread -I/usr/lib64/libffi/include   -DUSE_SENORA_GC-c
foreign.i -o foreign.o
foreign.i:1:1: warning: data definition has no type or storage class
1 | a, b;
  | ^
foreign.i:1:1: warning: type defaults to 'int' in declaration of 'a'
[-Wimplicit-int]
foreign.i:1:4: warning: type defaults to 'int' in declaration of 'b'
[-Wimplicit-int]
1 | a, b;
  |^
foreign.i:2:1: warning: return type defaults to 'int' [-Wimplicit-int]
2 | c() { d((void (*)()) & a + b); }
  | ^
foreign.i: In function 'c':
foreign.i:2:7: warning: implicit declaration of function 'd'
[-Wimplicit-function-declaration]
2 | c() { d((void (*)()) & a + b); }
  |   ^
foreign.i:2:32: warning: control reaches end of non-void function
[-Wreturn-type]
2 | c() { d((void (*)()) & a + b); }
  |^
during IPA pass: analyzer
foreign.i:2:7: internal compiler error: in get_or_create_mem_ref, at
analyzer/region-model.cc:6969
2 | c() { d((void (*)()) & a + b); }
  |   ^
0x763ce6 ana::region_model::get_or_create_mem_ref(tree_node*, ana::svalue_id,
ana::svalue_id, ana::region_model_context*)
../../gcc/gcc/analyzer/region-model.cc:6969
0x11c9585 ana::region_model::get_or_create_pointer_plus_expr(tree_node*,
ana::svalue_id, ana::svalue_id, ana::region_model_context*)
../../gcc/gcc/analyzer/region-model.cc:7058
0x11c9585 ana::region_model::on_assignment(gassign const*,
ana::region_model_context*)
../../gcc/gcc/analyzer/region-model.cc:4237
0x119bee2 ana::exploded_node::on_stmt(ana::exploded_graph&, ana::supernode
const*, gimple const*, ana::program_state*, ana::state_change*) const
../../gcc/gcc/analyzer/engine.cc:1019
0x119c841 ana::exploded_graph::process_node(ana::exploded_node*)
../../gcc/gcc/analyzer/engine.cc:2530
0x119ccb2 ana::exploded_graph::process_worklist()
../../gcc/gcc/analyzer/engine.cc:2348
0x119f07e ana::impl_run_checkers(ana::logger*)
../../gcc/gcc/analyzer/engine.cc:4029
0x11a0a7c ana::run_checkers()
../../gcc/gcc/analyzer/engine.cc:4097
0x1194808 execute
../../gcc/gcc/analyzer/analyzer-pass.cc:84
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.



However without the -fanalyzer flag it compiles and returns exit code 0.

[Bug analyzer/93288] ICE in supergraph.cc:180

2020-02-11 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93288

--- Comment #11 from pmatos at gcc dot gnu.org ---
(In reply to David Malcolm from comment #10)
> Should be fixed by the above commit.

David, does this mean the analyzer has C++ support now or just that this
specific bug is fixed in-tree?

[Bug analyzer/93288] ICE in supergraph.cc:180

2020-01-16 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93288

--- Comment #2 from pmatos at gcc dot gnu.org ---
(In reply to David Malcolm from comment #1)
> Note that C++ is out-of-scope for the analyzer for GCC 10.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x01cb37ed in supergraph::supergraph (this=0x7fffcda0,
> logger=0x0)
> at ../../src/gcc/analyzer/supergraph.cc:180
> 180   = ENTRY_BLOCK_PTR_FOR_FN (edge->callee->get_fun ());
> Missing separate debuginfos, use: dnf debuginfo-install
> gmp-6.1.2-10.fc30.x86_64 libmpc-1.1.0-3.fc30.x86_64
> libzstd-1.4.2-1.fc30.x86_64 mpfr-3.1.6-4.fc30.x86_64
> 
> (gdb) p edge->callee
> $1 = 
> 
> (gdb) p edge->callee->get_fun()->cfg
> $4 = (control_flow_graph *) 0x0
> 
> So it's a segfault reading through a NULL cfg pointer.

Ah - sorry. I was not aware of that. :)
I will test it on C only for now then. Thanks. Feel free to close this if you
wish.

[Bug analyzer/93288] New: ICE in supergraph.cc:180

2020-01-16 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93288

Bug ID: 93288
   Summary: ICE in supergraph.cc:180
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

Great work with the analyzer! :)

I am running it on WebKit and I find a few issues. At the moment they all seem
to point to supergraph.cc:180. Here's a reduced example with todays
(16.01.2020) GCC:

$ /home/pmatos/installs/gcc-20200116/bin/g++ -v   
Using built-in specs.
COLLECT_GCC=/home/pmatos/installs/gcc-20200116/bin/g++
COLLECT_LTO_WRAPPER=/home/pmatos/installs/gcc-20200116/libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/pmatos/installs/gcc-20200116
--enable-languages=c,c++,lto --disable-docs --disable-multilib --disable-nls
--disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.1 20200116 (experimental) (GCC)

Test case:

struct a {
  a();
};
class {
  a b;
} c;

$ /home/pmatos/installs/gcc-20200116/bin/g++ -std=gnu++17 -fanalyzer -c
AllIsoHeaps.ii
during IPA pass: analyzer
AllIsoHeaps.ii:6:4: internal compiler error: Segmentation fault
6 | } c;
  |^
0x105fbdf crash_signal
../../gcc/gcc/toplev.c:328
0x140d341 supergraph::supergraph(logger*)
../../gcc/gcc/analyzer/supergraph.cc:180
0x13d768f impl_run_checkers(logger*)
../../gcc/gcc/analyzer/engine.cc:3520
0x13d8d73 run_checkers()
../../gcc/gcc/analyzer/engine.cc:3624
0x13cdb28 execute
../../gcc/gcc/analyzer/analyzer-pass.cc:84
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

[Bug c/90758] New: out of bounds warning with -O3

2019-06-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90758

Bug ID: 90758
   Summary: out of bounds warning with -O3
   Product: gcc
   Version: 7.4.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

Created attachment 46455
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46455=edit
testcase

There's a bad out of bounds warning in gcc7 line which seems to be fixed in
gcc8 and later which only occurs with -O3.

With the attached file and the command line:
/home/pmatos/Projects/gcc-build/gcc/cc1 -fpreprocessed vfasl.i -quiet -dumpbase
vfasl.i -m64 -msse2 -mtune=generic -march=x86-64 -auxbase vfasl -O3
-Wpointer-arith -Wextra -Werror -Wimplicit-fallthrough=0 -Wall -version -o
/tmp/ccYGabNR.s   
GNU C11 (GCC) version 7.4.1 20190605 (x86_64-pc-linux-gnu)
compiled by GNU C version 8.2.1 20181127, GMP version 6.1.2, MPFR
version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C11 (GCC) version 7.4.1 20190605 (x86_64-pc-linux-gnu)
compiled by GNU C version 8.2.1 20181127, GMP version 6.1.2, MPFR
version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 4c52f0564d8672c9a189665c732e246d
vfasl.i: In function ‘l’:
vfasl.i:25:14: error: array subscript is above array bounds
[-Werror=array-bounds]
   ay = at[ax];
~~^~~~
vfasl.i: In function ‘j’:
vfasl.i:42:11: error: ‘n’ is used uninitialized in this function
[-Werror=uninitialized]
   *(a *)0 = n;
   ^~~
vfasl.i:45:3: note: ‘n’ was declared here
 a j(ac *m, a n) { return o(m, n); }
   ^
cc1: all warnings being treated as errors

[Bug middle-end/53917] Wuninitialized warning points to place where variable doesn't occur

2018-12-20 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53917

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pmatos at gcc dot gnu.org

--- Comment #5 from pmatos at gcc dot gnu.org ---
(In reply to Eric Gallager from comment #4)
> David Malcolm recently greatly improved variable use location info for GCC
> 9; reminder to myself to check to see if that fixed this once I've finished
> building a new GCC with the patch applied...

Thanks for taking time to look at this.

[Bug rtl-optimization/49884] get_last_value in combine ignores register mode

2018-12-17 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49884

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pmatos at gcc dot gnu.org

--- Comment #3 from pmatos at gcc dot gnu.org ---
I am not working anymore on this company and have no access to the original
code. I think we can safely close this bug.

[Bug other/50582] Instruct GCC that added_clobbers_hard_reg_p shouldn't consider a specific register

2018-09-28 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50582

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pmatos at gcc dot gnu.org

--- Comment #5 from pmatos at gcc dot gnu.org ---
(In reply to Eric Gallager from comment #4)
> 
> Do these patches still apply against trunk? If so, please submit to
> gcc-patches for review.

They are 7 years old. Most likely they don't apply. Will have to have another
go at them.

[Bug go/83071] gccgo: ICE in set_type

2017-11-21 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83071

--- Comment #5 from pmatos at gcc dot gnu.org ---
Thanks. It's working.

[Bug go/83071] gccgo: ICE in set_type

2017-11-20 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83071

--- Comment #2 from pmatos at gcc dot gnu.org ---
(In reply to Ian Lance Taylor from comment #1)
> This is of course a compiler bug, but it's a crash on invalid code.  You
> can't write `input++` when `input` is a string type.  In Go the `++`
> operator only applies to integer types.  When I fix the compiler bug, you
> will get an error compiling this code instead of a crash.

Go beginner here... as in... began today. :)
Thanks for the explanation. Can't wait to try the fixed gccgo.

[Bug go/83071] New: gccgo: ICE in set_type

2017-11-20 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83071

Bug ID: 83071
   Summary: gccgo: ICE in set_type
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: go
  Assignee: ian at airs dot com
  Reporter: pmatos at gcc dot gnu.org
CC: cmang at google dot com
  Target Milestone: ---

I have written a very simple program in Go and somehow I surprisingly managed
to crash the compiler.

This is my first Go program so maybe I am playing outside the normal rules...
still, it shouldn't ICE.

asmparser.go:


package asmparser

import "container/list"

// Structure representing assembler files
// An AsmFile is a list of assembler specific keywords and labels interspersed
with
// architectural specific instructions.
type AsmFile list.List

// Interface for entrie
type AsmEntry struct {
lineno int
entry  *Entry
}

type Entry interface {
isInsn() bool
isKeyword() bool
isLabel() bool
}

type Insn struct {
mnemonic string
args list.List
}

func (insn Insn) isInsn() bool {
return true
}

func (insn Insn) isKeyword() bool {
return false
}

func (insn Insn) isLabel() bool {
return false
}

type Keyword struct {
name string
args string
}

func (kw Keyword) isInsn() bool {
return false
}

func (kw Keyword) isKeyword() bool {
return true
}

func (kw Keyword) isLabel() bool {
return false
}

type Label struct {
name string
}

func (l Label) isInsn() bool {
return false
}

func (l Label) isKeyword() bool {
return true
}

func (l Label) isLabel() bool {
return false
}

// Hand-written parser
func EatWhitespace(input string) (string, int) {
var eaten int = 0
for len(input) > 0 {
if input[0] != ' ' {
return input, eaten
}
input++
eaten++
}
return input, eaten
}


$ go build
# gitlab.linki.tools/go-devtools/asmparser
go1: internal compiler error: in set_type, at
go/gofrontend/expressions.cc:16320
0x6013af Numeric_constant::set_type(Type*, bool, Location)
../../../gcc/gcc/go/gofrontend/expressions.cc:16320
0x8c06f9 Integer_expression::do_check_types(Gogo*)
../../../gcc/gcc/go/gofrontend/expressions.cc:2003
0x8dde63 Expression::check_types(Gogo*)
../../../gcc/gcc/go/gofrontend/expressions.h:902
0x8dde63 Check_types_traverse::expression(Expression**)
../../../gcc/gcc/go/gofrontend/gogo.cc:3297
0x8b190d Expression::traverse(Expression**, Traverse*)
../../../gcc/gcc/go/gofrontend/expressions.cc:45
0x8bb538 Expression_list::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/expressions.cc:15857
0x8e05b1 Block::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:5977
0x8e05b1 Block::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:5977
0x8e05b1 Block::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:5977
0x8e05b1 Block::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:5977
0x8e07c9 Function::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:5101
0x8e3ebb Bindings::traverse(Traverse*, bool)
../../../gcc/gcc/go/gofrontend/gogo.cc:7803
0x8e41d1 Gogo::traverse(Traverse*)
../../../gcc/gcc/go/gofrontend/gogo.cc:2497
0x8e44e6 Gogo::check_types()
../../../gcc/gcc/go/gofrontend/gogo.cc:3307
0x8dd76f go_parse_input_files(char const**, unsigned int, bool, bool)
../../../gcc/gcc/go/gofrontend/go.cc:133
0x8d8bcf go_langhook_parse_file
../../../gcc/gcc/go/go-lang.c:323
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Fails wth both gccgo 7.2.1 (distributed with Fedora) and 
$ go version
go version go1.9 gccgo (GCC) 8.0.0 20171120 (experimental) linux/amd64

which I just built locally.

[Bug middle-end/72818] No warning for dereferencing casted pointer

2016-08-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72818

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from pmatos at gcc dot gnu.org ---
octoploid in IRC pointed out that GCC warns about this with
-Wstrict-aliasing=2:
$ gcc -Wstrict-aliasing=2 -Os -c -ocast.s cast.c
cast.c: In function ‘foo’:
cast.c:1:1: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
 void foo(unsigned char x){unsigned int *y=(unsigned int *) *y=0x12345678;}
 ^

Closing as invalid.

[Bug middle-end/72818] No warning for dereferencing casted pointer

2016-08-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72818

--- Comment #1 from pmatos at gcc dot gnu.org ---
Please disregard the -fsanitize=undefined in my initial comment. I didn't
expect -fsanitize=undefined to caught it. That was an artefact from my original
example. I expected a warning from GCC at compile time similar to that of the
former example.

[Bug middle-end/72818] New: No warning for dereferencing casted pointer

2016-08-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72818

Bug ID: 72818
   Summary: No warning for dereferencing casted pointer
   Product: gcc
   Version: 5.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org
  Target Milestone: ---

GCC appropriately generates a warning for:
void f(char c){*(unsigned*)=0;}

$ gcc -Wall -fsanitize=undefined -Os -c -ocast1.s cast1.c
cast1.c: In function ‘f’:
cast1.c:1:1: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
 void f(char c){*(unsigned*)=0;}
 ^
$

But not for:
void foo(unsigned char x){unsigned int *y=(unsigned int *) *y=0x12345678;}

$ gcc -Wall -fsanitize=undefined -Os -c -ocast.s cast.c
$

It would seem this latter case should be caught and reported as well.

[Bug c/16351] NULL dereference warnings

2015-05-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16351

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pmatos at gcc dot gnu.org

--- Comment #25 from pmatos at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #24)
 I can give you many examples of old must-have bugs that are easy to fix,
 but simply there is no one with enough time and motivation to get them done.

It would be interesting to have that list. Or just those on the top of your
head. I might not necessarily look at them now but I know I will have some time
in the near future to work on a few of these, so it would be interesting to
have this list so I can look at them.

Thanks.

[Bug c/16351] NULL dereference warnings

2015-05-05 Thread pmatos at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16351

--- Comment #27 from pmatos at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #26)
 A good place to start is
 https://gcc.gnu.org/bugzilla/buglist.
 cgi?keywords=easyhacklist_id=116934order=bug_idquery_format=advanced
 

Thanks for the input. I will take a look.

[Bug middle-end/60591] New: Report enum conversions as part of Wconversion

2014-03-19 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60591

Bug ID: 60591
   Summary: Report enum conversions as part of Wconversion
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org

enum xpto
{
  A = 0,
  B = 1,
  X = 512
};
extern void print (unsigned int);

unsigned char bar (enum xpto a)
{
   return a;
}


We don't get currently a warning for this return conversion if we use
--short-enums. With -O2 --short-enums, sizeof enum xpto == 2, but sizeof
unsigned char == 1, therefore we should warn the user there's loss of
precision.


[Bug c/60410] New: -fshort-double ICEs x86_64

2014-03-04 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60410

Bug ID: 60410
   Summary: -fshort-double ICEs x86_64
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pmatos at gcc dot gnu.org

Created attachment 32259
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=32259action=edit
Testcase for this bug (and pr55113 as well)

After fixing PR55113, I noticed that the testcase gcc.dg/lto/pr55113_0.c ICEs
x86_64:

$ top-trunk/toolchain/install-native/bin/gcc -O2 -o test pr55113_0.c
-fshort-double 
built-in: internal compiler error: in layout_type, at stor-layout.c:2116
0xb36233 layout_type(tree_node*)
../../../src/gcc/gcc/stor-layout.c:2115
0xdf8998 make_vector_type
../../../src/gcc/gcc/tree.c:9431
0xdfbb87 build_vector_type_for_mode(tree_node*, machine_mode)
../../../src/gcc/gcc/tree.c:10205
0xe8dd57 ix86_get_builtin_type
../../../src/gcc/gcc/config/i386/i386.c:27021
0xe8de95 ix86_get_builtin_func_type
../../../src/gcc/gcc/config/i386/i386.c:27071
0xe8dfa1 def_builtin
../../../src/gcc/gcc/config/i386/i386.c:28787
0xe8e662 ix86_init_mmx_sse_builtins
../../../src/gcc/gcc/config/i386/i386.c:30724
0xe92e8f ix86_init_builtins
../../../src/gcc/gcc/config/i386/i386.c:32677
0x62c692 c_define_builtins
../../../src/gcc/gcc/c-family/c-common.c:5268
0x62e09c c_common_nodes_and_builtins()
../../../src/gcc/gcc/c-family/c-common.c:5712
0x57b859 c_init_decl_processing()
../../../src/gcc/gcc/c/c-decl.c:3550
0x5d260f c_objc_common_init()
../../../src/gcc/gcc/c/c-objc-common.c:63
0xb4333c lang_dependent_init
../../../src/gcc/gcc/toplev.c:1712
0xb4374a do_compile
../../../src/gcc/gcc/toplev.c:1900
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See http://gcc.gnu.org/bugs.html for instructions.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-03-04 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #18 from pmatos at gcc dot gnu.org ---
Fixed in r208312.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-03-02 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #17 from pmatos at gcc dot gnu.org ---
Patch submitted to gcc-patches.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-28 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #16 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #14)
 
 Well.  At least to my theory (didn't try).
 

Theory and practice match. It seems to fix the bug and work fine. I will do
some further testing and post a patch. 

Thanks.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #15 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #14)
 See above - if that works I'd prefer that.

Makes sense. Thanks Richard. I will give that a try and if everything looks ok
I will prepare a patch today along with a testcase.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-26 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #13 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #11)
 If double_type_node is FE dependent then it needs treatment in
 tree-streamer.c:preload_common_nodes:
 
 static void
 preload_common_nodes (struct streamer_tree_cache_d *cache)
 {
   unsigned i;
 
   for (i = 0; i  itk_none; i++)
 /* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
 if (i != itk_char)
   record_common_node (cache, integer_types[i]);
 
   for (i = 0; i  stk_type_kind_last; i++)
 record_common_node (cache, sizetype_tab[i]);
 
   for (i = 0; i  TI_MAX; i++)
 /* Skip boolean type and constants, they are frontend dependent.  */
 if (i != TI_BOOLEAN_TYPE
  i != TI_BOOLEAN_FALSE
  i != TI_BOOLEAN_TRUE)
   record_common_node (cache, global_trees[i]);
 }

Richard,
I tried what you suggested but led me nowhere. In the meantime I noticed that
-fshort-double shows up in COLLECT_GCC_OPTIONS before collect2 is called:

COLLECT_GCC_OPTIONS='-fshort-double' '-flto' '-nostdlib' '-o' 'test'
'-save-temps' '-v' '-da' '-fdump-tree-all-all' '-mcpu=8540'

/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/collect2
-plugin
/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/liblto_plugin.so
-plugin-opt=/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/lto-wrapper
-plugin-opt=-fresolution=pr55113.res -flto
--sysroot=/home/pmatos/work/pr55113/top-4_8/toolchain/prex_sysroot
--eh-frame-hdr -V -dn -Bstatic -o test
-L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-eabispe/4.8.3
-L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-eabispe/4.8.3/../../../../powerpc-eabispe/lib
pr55113.o

but not after when lto1 is called:
COLLECT_GCC_OPTIONS='-c' '-mcpu=8540' '-nostdlib' '-save-temps' '-v' '-da'
'-fdump-tree-all-all' '-mcpu=8540' '-dumpdir' './' '-dumpbase' 'test.wpa'
'-fltrans-output-list=test.ltrans.out' '-fwpa' '-fresolution=pr55113.res'

/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/lto1
-quiet -da -dumpdir ./ -dumpbase test.wpa -mcpu=8540 -mcpu=8540 -auxbase
pr55113 -version -fdump-tree-all-all -fltrans-output-list=test.ltrans.out -fwpa
-fresolution=pr55113.res @/tmp/ccW7YQPl

Somewhere along the line the option is lost. It seems to be that only some
options are kept and optimization options are lost, like fshort-double.
However, in lto/lto-lang.c:lto_init you have:
  /* Create the basic integer types.  */
  build_common_tree_nodes (flag_signed_char, /*short_double=*/false);

This hardcodes short double to false. If I were to hardcode this to true,
Patricks example would work.

I think similarly to what we do in c-family/c-common.c:
  build_common_tree_nodes (flag_signed_char, flag_short_double);

we need to pass flag_short_double but the only way to do so is by letting
fshort-double pass through the flag filtering that goes on before lto1 is
called.

I will prepare a patch to add this exception, let me know if you think there's
a better way.


[Bug rtl-optimization/59999] [4.9 Regression] Sign extension in loop regression blocks generation of zero overhead loop

2014-02-12 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #24 from pmatos at gcc dot gnu.org ---
Closing as invalid. Thanks Richard.


[Bug middle-end/58463] ICE with -fdump-tree-all-all in vector indexed access

2013-09-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58463

--- Comment #8 from pmatos at gcc dot gnu.org ---
Author: pmatos
Date: Fri Sep 27 14:54:43 2013
New Revision: 202976

URL: http://gcc.gnu.org/viewcvs?rev=202976root=gccview=rev
Log:
PR middle-end/58463
* gcc.dg/pr58463.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr58463.c
Modified:
trunk/gcc/ChangeLog


[Bug tree-optimization/58463] ICE with -fdump-tree-all-all in vector indexed access

2013-09-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58463

--- Comment #9 from pmatos at gcc dot gnu.org ---
Author: pmatos
Date: Fri Sep 27 16:30:15 2013
New Revision: 202978

URL: http://gcc.gnu.org/viewcvs?rev=202978root=gccview=rev
Log:
Backport from mainline.

2013-09-27  Paulo Matos  pma...@broadcom.com
PR middle-end/58463
* gcc.dg/pr58463.c: New test.

Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/pr58463.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog


[Bug target/56716] during gcc 4.8.0 build on Cygwin: bid128_fma.c:4460:1: internal compiler error: Segmentation fault

2013-09-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56716

--- Comment #11 from pmatos at gcc dot gnu.org ---
Author: pmatos
Date: Fri Sep 27 16:44:39 2013
New Revision: 202979

URL: http://gcc.gnu.org/viewcvs?rev=202979root=gccview=rev
Log:
Backport from mainline.

 PR middle-end/58463
 2013-03-27  Richard Biener  rguent...@suse.de

 PR tree-optimization/56716
 * tree-ssa-structalias.c (perform_var_substitution): Adjust
 dumping for ref nodes.

Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/tree-ssa-structalias.c


[Bug middle-end/58463] ICE with -fdump-tree-all-all in vector indexed access

2013-09-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58463

--- Comment #10 from pmatos at gcc dot gnu.org ---
Author: pmatos
Date: Fri Sep 27 16:44:39 2013
New Revision: 202979

URL: http://gcc.gnu.org/viewcvs?rev=202979root=gccview=rev
Log:
Backport from mainline.

 PR middle-end/58463
 2013-03-27  Richard Biener  rguent...@suse.de

 PR tree-optimization/56716
 * tree-ssa-structalias.c (perform_var_substitution): Adjust
 dumping for ref nodes.

Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/tree-ssa-structalias.c