public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/67025] New: Missing aggressive loop optimization warning when -fPIC used
@ 2015-07-27 11:42 Nikola.Veljkovic at imgtec dot com
0 siblings, 0 replies; only message in thread
From: Nikola.Veljkovic at imgtec dot com @ 2015-07-27 11:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67025
Bug ID: 67025
Summary: Missing aggressive loop optimization warning when
-fPIC used
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: Nikola.Veljkovic at imgtec dot com
Target Milestone: ---
The issue here is not that the loop is over optimized, but the fact that the
warning is missing.
Without the warning debugging an issue like this takes much longer.
Source code:
main.c:
#include <stdio.h>
struct problem {
int* array1[4];
int* array2[4];
};
int* foo() { return 0; }
int main(int argc, int** argv) {
int i;
struct problem p;
for(i = 0; i < 8; i++) {
printf("i=%d\n", i);
p.array1[i] = foo();
if(p.array1[i]) return -1;
}
return 0;
}
Compilation (with -fPIC):
$ gcc-5 -O2 -fPIC -o for-test main.c
Compilation (without -fPIC):
$ gcc-5 -O2 -o for-test main.c
main.c: In function ‘main’:
main.c:15:21: warning: iteration 4u invokes undefined behavior
[-Waggressive-loop-optimizations]
p.array1[i] = foo();
^
main.c:13:5: note: containing loop
for(i = 0; i < 8; i++) {
Compilation is successful in both cases, but the warning is missing when
compiling with -fPIC.
Execution: The loop executes indefinitely in both cases.
Tested on last week's build of gcc-5.2 release built for mips, and on Ubuntu
14.04 (i686 package) gcc-5.1.
Should be reproducible on any architecture with compiler version 4.9 and above.
I can provide any additional info, if required.
>From gcc-bugs-return-493447-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 27 12:41:22 2015
Return-Path: <gcc-bugs-return-493447-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 76861 invoked by alias); 27 Jul 2015 12:41:22 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 76783 invoked by uid 55); 27 Jul 2015 12:41:18 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66555] Fails to warn for if (j == 0 && i == i)
Date: Mon, 27 Jul 2015 12:41: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: 6.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66555-4-ULwfyMUrzf@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66555-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66555-4@http.gcc.gnu.org/bugzilla/>
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-07/txt/msg02337.txt.bz2
Content-length: 1422
https://gcc.gnu.org/bugzilla/show_bug.cgi?idf555
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Mon Jul 27 12:40:45 2015
New Revision: 226242
URL: https://gcc.gnu.org/viewcvs?rev"6242&root=gcc&view=rev
Log:
PR c++/66555
PR c/54979
* c-common.c (find_array_ref_with_const_idx_r): New function.
(warn_tautological_cmp): New function.
* c-common.h (warn_tautological_cmp): Declare.
* c.opt (Wtautological-compare): New option.
* c-typeck.c (parser_build_binary_op): Call warn_tautological_cmp.
* call.c (build_new_op_1): Call warn_tautological_cmp.
* pt.c (tsubst_copy_and_build): Use sentinel to suppress tautological
compare warnings.
* doc/invoke.texi: Document -Wtautological-compare.
* c-c++-common/Wtautological-compare-1.c: New test.
Added:
trunk/gcc/testsuite/c-c++-common/Wtautological-compare-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/c-family/c.opt
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/pt.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/cpp0x/decltype-54581.C
trunk/gcc/testsuite/g++.dg/other/vector-compare.C
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-27 11:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 11:42 [Bug c/67025] New: Missing aggressive loop optimization warning when -fPIC used Nikola.Veljkovic at imgtec dot com
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).