public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/61526] relocation R_X86_64_PC32 in shared object with static and extern Date: Mon, 21 Jul 2014 16:17:00 -0000 [thread overview] Message-ID: <bug-61526-4-LQIhcdMTEG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-61526-4@http.gcc.gnu.org/bugzilla/> [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 9096 bytes --] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61526 --- Comment #4 from UroÅ¡ Bizjak <ubizjak at gmail dot com> --- (In reply to Sandra Loosemore from comment #3) > The testcase added for this bug in GCC 4.9.1 is failing with a link error on > an arm-none-eabi target that doesn't support -shared. Should it be > restricted to linux targets? Probably the best way is to add check_effective_target_shared to lib/target-supports.exp (similar to existing c_e_t_static) procedure and use it through the testsuite. >From gcc-bugs-return-456873-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 21 17:33:09 2014 Return-Path: <gcc-bugs-return-456873-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 2330 invoked by alias); 21 Jul 2014 17:33:08 -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 2194 invoked by uid 48); 21 Jul 2014 17:33:01 -0000 From: "coleb at eyesopen dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61872] New: Assigning to "long double" causes memset to be improperly elided Date: Mon, 21 Jul 2014 17:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: coleb at eyesopen 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-61872-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-07/txt/msg01464.txt.bz2 Content-length: 6683 https://gcc.gnu.org/bugzilla/show_bug.cgi?ida872 Bug ID: 61872 Summary: Assigning to "long double" causes memset to be improperly elided Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: coleb at eyesopen dot com Created attachment 33169 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3169&actioníit Intermediate file generated by the compiler for the above test case The following code zeros out memory being used as a "long double" in order to be able to memcmp the memory later. However, assigning to the long double later causes the optimizer to omit the preceding memset of zero. The following code boils this down to a simple test case: #include <assert.h> #include <string.h> #include <iomanip> #include <iostream> void Dump( const void * mem, size_t n ) { const unsigned char * p = reinterpret_cast< const unsigned char *>( mem ); for ( size_t i = 0; i < n; i++ ) { std::cout << std::hex << std::setw(2) << std::setfill( std::cout.widen('0') ) << int(p[i]) << " "; } std::cout << std::endl; } int main() { long double a; memset(&a, '\0', sizeof(long double)); //Dump(&a, sizeof(long double)); // Uncomment me to make the test pass a = 1.0; long double b; memset(&b, '\0', sizeof(long double)); //Dump(&b, sizeof(long double)); // Uncomment me to make the test pass b = 1.0; std::cout << memcmp(&a, &b, sizeof(long double)) << std::endl; Dump(&a, sizeof(long double)); Dump(&b, sizeof(long double)); assert(memcmp(&a, &b, sizeof(long double)) == 0); } Uncommenting the "Dump" function calls causing the test to pass, presumably because the optimizer notices the zero'd out memory is now being used by Dump before the assignment. Note, this only occurs with -O1 or higher. I've attached the associated .ii files from the following command: coleb@rhel7:~> g++ -v -save-temps -O1 ./LongDoubleMemSetElided.cpp && ./a.out Using built-in specs. COLLECT_GCC=g++ 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 --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20131106/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131106/obj-x86_64-redhat-linux/cloog-install --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.2 20131106 (Red Hat 4.8.2-3) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O1' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1plus -E -quiet -v -D_GNU_SOURCE ./LongDoubleMemSetElided.cpp -mtune=generic -march=x86-64 -O1 -fpch-preprocess -o LongDoubleMemSetElided.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../x86_64-redhat-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/x86_64-redhat-linux /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/backward /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include /usr/local/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O1' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1plus -fpreprocessed LongDoubleMemSetElided.ii -quiet -dumpbase LongDoubleMemSetElided.cpp -mtune=generic -march=x86-64 -auxbase LongDoubleMemSetElided -O1 -version -o LongDoubleMemSetElided.s GNU C++ (GCC) version 4.8.2 20131106 (Red Hat 4.8.2-3) (x86_64-redhat-linux) compiled by GNU C version 4.8.2 20131106 (Red Hat 4.8.2-3), GMP version 5.1.1, MPFR version 3.1.1, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand\x100 --param ggc-min-heapsize\x131072 GNU C++ (GCC) version 4.8.2 20131106 (Red Hat 4.8.2-3) (x86_64-redhat-linux) compiled by GNU C version 4.8.2 20131106 (Red Hat 4.8.2-3), GMP version 5.1.1, MPFR version 3.1.1, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand\x100 --param ggc-min-heapsize\x131072 Compiler executable checksum: 854a658c8d093bd199c43bf0150da7d8 COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O1' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o LongDoubleMemSetElided.o LongDoubleMemSetElided.s GNU assembler version 2.23.52.0.1 (x86_64-redhat-linux) using BFD version version 2.23.52.0.1-12.el7 20130226 COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/:/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.8.2/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/:/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O1' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/collect2 --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../.. LongDoubleMemSetElided.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.8.2/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crtn.o 64 00 00 00 00 00 00 00 80 ff 3f 40 00 00 00 00 00 00 00 00 00 00 00 00 80 ff 3f 00 00 00 00 00 00 a.out: ./LongDoubleMemSetElided.cpp:33: int main(): Assertion `memcmp(&a, &b, sizeof(long double)) == 0' failed. Aborted (core dumped) Thank you!
prev parent reply other threads:[~2014-07-21 16:17 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-06-16 14:48 [Bug lto/61526] New: " khimov at altell dot ru 2014-06-17 9:00 ` [Bug lto/61526] " rguenth at gcc dot gnu.org 2014-06-17 9:28 ` khimov at altell dot ru 2014-07-21 16:00 ` sandra at codesourcery dot com 2014-07-21 16:17 ` ubizjak at gmail dot com [this message]
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-61526-4-LQIhcdMTEG@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: linkBe 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).