public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59976] New: Spurious warning on converting const int variable to unsigned long
@ 2014-01-29  7:39 chengniansun at gmail dot com
  2014-02-04 23:16 ` [Bug c/59976] Spurious warning on converting const int variable to unsigned long (Also inconsistency between O0 and O1) chengniansun at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: chengniansun at gmail dot com @ 2014-01-29  7:39 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 7319 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59976

            Bug ID: 59976
           Summary: Spurious warning on converting const int variable to
                    unsigned long
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

I define a static global variable "g" of type "const int", with a value 0. When
assigning it to a variable of type unsigned long, Gcc emits a warning on the
signedness conversion. As "g" is not modifiable and equivalent to "0", there is
no signedness conversion actually. 




$: cat s.c
static const int g = 0;
void fn() {
  unsigned long l = g;
}
$: gcc-trunk -c -Wconversion s.c
s.c: In function ‘fn’:
s.c:3:3: warning: conversion to ‘long unsigned int’ from ‘int’ may change the
sign of the result [-Wsign-conversion]
   unsigned long l = g;
   ^
$: gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/chengniansun/tools/gcc-trunk-binaries/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/chengniansun/tools/gcc-trunk-binaries :
(reconfigured) ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/chengniansun/tools/gcc-trunk-binaries
Thread model: posix
gcc version 4.9.0 20140127 (experimental) (GCC)
$:
$: clang-trunk -c -Wconversion s.c
$:
>From gcc-bugs-return-441835-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jan 29 08:56:38 2014
Return-Path: <gcc-bugs-return-441835-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 30819 invoked by alias); 29 Jan 2014 08:56:37 -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 30804 invoked by uid 48); 29 Jan 2014 08:56:32 -0000
From: "nheghathivhistha at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/59977] New: lto1: internal compiler error: bytecode stream: expected tag real_type instead of error_mark
Date: Wed, 29 Jan 2014 08:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 4.9.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 attachments.created
Message-ID: <bug-59977-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: 2014-01/txt/msg02977.txt.bz2
Content-length: 3787

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY977

            Bug ID: 59977
           Summary: lto1: internal compiler error: bytecode stream:
                    expected tag real_type instead of error_mark
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nheghathivhistha at gmail dot com

Created attachment 31975
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1975&actioníit
un-reduced gzipped preprocessed file

When I remove libraries it not ICEs.
Creduce is stuck at beginning and not able to remove any line.
When I ran
cat testcase.i | grep -v '^# .*$' | grep -v '^[[:space:]]*$' > testcase.x
on ii file and test the resulting files with comments removed it not ICEs with
the same compilation command.

gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.0-alpha20140128/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.9.0-alpha20140128/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.9.0_alpha20140128/work/gcc-4.9-20140128/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.9.0-alpha20140128
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0-alpha20140128/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.0-alpha20140128
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.0-alpha20140128/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.0-alpha20140128/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0-alpha20140128/include/g++-v4
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.9.0-alpha20140128/python
--enable-languages=c,c++,java,go,objc,obj-c++,fortran,ada --enable-obsolete
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.9.0_alpha20140128' --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --disable-altivec --disable-fixed-point
--enable-targets=all --enable-java-awt=gtk --enable-libgomp --enable-lto
--without-cloog
Thread model: posix
gcc version 4.9.0-alpha20140128 20140129 (experimental) [trunk revision 207224]
(Gentoo 4.9.0_alpha20140128)

The command is:

LC_ALL=C LANG=C  /usr/bin/x86_64-pc-linux-gnu-g++  -fPIC -flto=4
-fuse-linker-plugin -O2 -ggdb -pipe -march=native -mtune=native
-Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall
-W -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS
-fno-check-new -fno-common -Woverloaded-virtual -fno-threadsafe-statics
-fvisibility=hidden -fvisibility-inlines-hidden  -march=core2 -msse2 -msse3
-mssse3 -msse4.1 -mno-sse4.2 -mno-sse4a -mno-avx -mno-xop -mno-fma4  -Wabi
-fabi-version=0 -ffp-contractúst -Wl,--enable-new-dtags -Wl,--no-undefined
-lc  -flto=4 -fuse-linker-plugin -Wl,--as-needed -Wl,-O2 -O2 -ggdb -pipe
-march=native -mtune=native -shared -Wl,-soname,libpigmentcms.so.13 -o
/dev/null
/var/tmp/portage/app-office/calligra-2.7.91/work/calligra-2.7.91_build/libs/pigment/KoOptimizedCompositeOpFactoryPerArch_Scalar.ii
-L/var/tmp/portage/app-office/calligra-2.7.91/work/calligra-2.7.91_build/lib
-L/usr/lib64/qt4
/var/tmp/portage/app-office/calligra-2.7.91/work/calligra-2.7.91_build/lib/libkoplugin.so.13.0.0
-lImath -lIlmImf -lIex -lHalf -lIlmThread -Wl,-Bstatic -lVc -Wl,-Bdynamic
/usr/lib64/qt4/libQtGui.so /usr/lib64/qt4/libQtXml.so
/usr/lib64/libkdecore.so.5.12.1 /usr/lib64/qt4/libQtDBus.so
/usr/lib64/qt4/libQtCore.so -lpthread

How can I reduce it please?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/59976] Spurious warning on converting const int variable to unsigned long (Also inconsistency between O0 and O1)
  2014-01-29  7:39 [Bug c/59976] New: Spurious warning on converting const int variable to unsigned long chengniansun at gmail dot com
@ 2014-02-04 23:16 ` chengniansun at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: chengniansun at gmail dot com @ 2014-02-04 23:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59976

Chengnian Sun <chengniansun at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Spurious warning on         |Spurious warning on
                   |converting const int        |converting const int
                   |variable to unsigned long   |variable to unsigned long
                   |                            |(Also inconsistency between
                   |                            |O0 and O1)

--- Comment #1 from Chengnian Sun <chengniansun at gmail dot com> ---
The warning is gone if I compile the program with -O1. 

I also have a similar example below:

$: cat s.c
unsigned g;
void fn1() {
  int a;
  const unsigned char b = 0;
  a = b & g;
}
$: gcc-trunk -c -Wconversion -O0 s.c
s.c: In function ‘fn1’:
s.c:5:7: warning: conversion to ‘int’ from ‘unsigned int’ may change the sign
of the result [-Wsign-conversion]
   a = b & g;
       ^
$: gcc-trunk -c -Wconversion -O1 s.c
$:
>From gcc-bugs-return-442590-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Feb 04 23:53:50 2014
Return-Path: <gcc-bugs-return-442590-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 5131 invoked by alias); 4 Feb 2014 23:53:49 -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 5111 invoked by uid 48); 4 Feb 2014 23:53:45 -0000
From: "msebor at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60063] -Wunused-local-typedefs warning despite attribute used in a template
Date: Tue, 04 Feb 2014 23:53: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: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: msebor 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:
Message-ID: <bug-60063-4-BbKoatAp2C@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60063-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60063-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: 2014-02/txt/msg00347.txt.bz2
Content-length: 592

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`063

--- Comment #1 from Martin Sebor <msebor at gmail dot com> ---
I confused attribute used with unused in the test case. With the latter, the
warning is not emitted as one would expect. Attribute used isn't documented for
types, so it's not completely clear whether the test is valid.

Searching through the test suite, I came across Wunused-local-typedefs.c
(apparently added for bug 33255) which exercises attribute used with a typedef,
albeit in C code, so the test case might be valid after all and the
documentation might need updating.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-04 23:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-29  7:39 [Bug c/59976] New: Spurious warning on converting const int variable to unsigned long chengniansun at gmail dot com
2014-02-04 23:16 ` [Bug c/59976] Spurious warning on converting const int variable to unsigned long (Also inconsistency between O0 and O1) chengniansun at gmail 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).