public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gnome3fans at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58928] Different results from gcc when -mlzcnt is used
Date: Tue, 10 Dec 2013 07:06:00 -0000	[thread overview]
Message-ID: <bug-58928-4-Esa8Z67lX9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58928-4@http.gcc.gnu.org/bugzilla/>

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

chenjinzhi <gnome3fans at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gnome3fans at gmail dot com

--- Comment #1 from chenjinzhi <gnome3fans at gmail dot com> ---
(In reply to Michael Barker from comment #0)
> Created attachment 31113 [details]
> Preprossed test.c code
> 
> I have the following code:
> 
> #include <stdint.h>
> #include <stdio.h>
> #include <x86intrin.h>
> 
> long long lzcnt(long long l)
> {
> 	return __lzcnt64(l);
> }
> 
> int main(int argc, char** argv)
> {
> 	printf("%lld\n", lzcnt(atoll(argv[1])));
> 	return 0;
> }
> 
> If I compile and run with and without the -mlzcnt flag I get different
> results:
> 
> $ gcc src/test.c -D__LZCNT__ -mlzcnt && ./a.out 2047
> 10
> 
> $ gcc src/test.c -D__LZCNT__ && ./a.out 2047
> 53
> 
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
> Target: x86_64-redhat-linux
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
> --enable-bootstrap --enable-shared --enable-threads=posix
> --enable-checking=release --with-system-zlib --enable-__cxa_atexit
> --disable-libunwind-exceptions --enable-gnu-unique-object
> --enable-linker-build-id --with-linker-hash-style=gnu
> --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto
> --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi
> --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
> --enable-libgcj-multifile --enable-java-maintainer-mode
> --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
> --with-isl=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/
> isl-install
> --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-
> linux/cloog-install --with-tune=generic --with-arch_32=i686
> --build=x86_64-redhat-linux
> Thread model: posix
> gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC) 
> 
> File test.i attached.  It was the same for both compilations, so only one
> file attached.

I just test the code in my machine but the result is different from yours.
I compile and run with and without the -mlzcnt flag and get the same result:
53.

Here is my gcc -v output:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-isl=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC)

Hope helps
>From gcc-bugs-return-437156-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 10 07:06:05 2013
Return-Path: <gcc-bugs-return-437156-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21033 invoked by alias); 10 Dec 2013 07:06:04 -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 21000 invoked by uid 48); 10 Dec 2013 07:06:01 -0000
From: "conradsand.arma at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function
Date: Tue, 10 Dec 2013 07:06: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: major
X-Bugzilla-Who: conradsand.arma 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-59364-4-bs1gNKKsa8@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59364-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59364-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: 2013-12/txt/msg00811.txt.bz2
Content-length: 598

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

--- Comment #3 from Conrad <conradsand.arma at gmail dot com> ---
Reduced test case.  Compile with:

g++ a.cpp -c -o a.o -std=c++11
g++ b.cpp -c -o b.o -std=c++11
g++ a.o b.o -o prog -std=c++11

file foo.hpp:

class foo
  {
  public:

  inline  foo() {}
  inline ~foo() {}

  inline double bar() { return 123.456; }
  };


file a.cpp:

#include "foo.hpp"
thread_local foo foo_instance;


file b.cpp:

#include "foo.hpp"
extern thread_local foo foo_instance;

int main(int argc, char** argv)
  {
  double bar = foo_instance.bar();
  return 0;
  }


  reply	other threads:[~2013-12-10  7:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30 20:05 [Bug c/58928] New: " mikeb01 at gmail dot com
2013-12-10  7:06 ` gnome3fans at gmail dot com [this message]
2014-01-17  1:18 ` [Bug target/58928] " mikeb01 at gmail dot com
2014-01-17 10:31 ` jtaylor.debian at googlemail dot com
2014-01-17 11:16 ` jakub at gcc dot gnu.org
2014-01-19  0:44 ` mikeb01 at gmail dot com
2014-01-20 23:48 ` mikeb01 at gmail dot com
2014-01-20 23:48 ` mikeb01 at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58928-4-Esa8Z67lX9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).