public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary
@ 2012-07-20 23:08 jason at cornsyrup dot org
  2012-07-20 23:11 ` [Bug c++/54059] " jason at cornsyrup dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jason at cornsyrup dot org @ 2012-07-20 23:08 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54059
           Summary: g++ silently omits code that creates a
                    std::chrono::millisecond temporary
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jason@cornsyrup.org


jason@ps027 ~/bug$ g++-4.7 -std=c++11 bug.cc 
jason@ps027 ~/bug$ ./a.out 
got 100
jason@ps027 ~/bug$ cat bug.cc 

#include <chrono>
#include <iostream>

struct foo {
    foo(std::chrono::milliseconds ms) {
        std::cout << "got " << ms.count() << "\n";
    }
};

int main() {
    foo f1(std::chrono::milliseconds(100));
    unsigned int a = 200;
    foo f2(std::chrono::milliseconds(a));
    return 0;
}
jason@ps027 ~/bug$ g++-4.7 -v
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.1-4+ub1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--enable-objc-gc --disable-werror --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.1 (Ubuntu/Linaro 4.7.1-4+ub1)


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

* [Bug c++/54059] g++ silently omits code that creates a std::chrono::millisecond temporary
  2012-07-20 23:08 [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary jason at cornsyrup dot org
@ 2012-07-20 23:11 ` jason at cornsyrup dot org
  2012-07-20 23:12 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jason at cornsyrup dot org @ 2012-07-20 23:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Toffaletti <jason at cornsyrup dot org> 2012-07-20 23:11:37 UTC ---
$ g++-4.7 -c -g -Wa,-alh -std=c++11 bug.cc
<snip>
 155                    .LEHE0:
  13:bug.cc        ****     unsigned int a = 200;
 156                            .loc 2 13 0 discriminator 1
 157 0035 C745ECC8              movl    $200, -20(%rbp)
 157      000000
  14:bug.cc        ****     foo f2(std::chrono::milliseconds(a));
  15:bug.cc        ****     return 0;
 158                            .loc 2 15 0 discriminator 1
 159 003c B8000000              movl    $0, %eax
 159      00
 160 0041 EB08                  jmp     .L9
 161                    .L8:
 162 0043 4889C7                movq    %rax, %rdi
 163                    .LEHB1:
 164 0046 E8000000              call    _Unwind_Resume
 164      00
 165                    .LEHE1:
 166                    .L9:
 167                    .LBE4:
  16:bug.cc        **** }
<snip>


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

* [Bug c++/54059] g++ silently omits code that creates a std::chrono::millisecond temporary
  2012-07-20 23:08 [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary jason at cornsyrup dot org
  2012-07-20 23:11 ` [Bug c++/54059] " jason at cornsyrup dot org
@ 2012-07-20 23:12 ` pinskia at gcc dot gnu.org
  2012-07-20 23:14 ` redi at gcc dot gnu.org
  2012-07-20 23:17 ` jason at cornsyrup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-07-20 23:12 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-20 23:12:23 UTC ---
>    foo f2(std::chrono::milliseconds(a));

This is a function declaration and not a variable definition ...


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

* [Bug c++/54059] g++ silently omits code that creates a std::chrono::millisecond temporary
  2012-07-20 23:08 [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary jason at cornsyrup dot org
  2012-07-20 23:11 ` [Bug c++/54059] " jason at cornsyrup dot org
  2012-07-20 23:12 ` pinskia at gcc dot gnu.org
@ 2012-07-20 23:14 ` redi at gcc dot gnu.org
  2012-07-20 23:17 ` jason at cornsyrup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-20 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-20 23:14:09 UTC ---
This is http://en.wikipedia.org/wiki/Most_vexing_parse

The declaration f2 declares a function, it is not a variables definition.

To convince yourself, try taking its address:

foo* p = &f2;


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

* [Bug c++/54059] g++ silently omits code that creates a std::chrono::millisecond temporary
  2012-07-20 23:08 [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary jason at cornsyrup dot org
                   ` (2 preceding siblings ...)
  2012-07-20 23:14 ` redi at gcc dot gnu.org
@ 2012-07-20 23:17 ` jason at cornsyrup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at cornsyrup dot org @ 2012-07-20 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Toffaletti <jason at cornsyrup dot org> 2012-07-20 23:16:56 UTC ---
I knew there was something familiar about this, thanks for the reminder.


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

end of thread, other threads:[~2012-07-20 23:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20 23:08 [Bug c++/54059] New: g++ silently omits code that creates a std::chrono::millisecond temporary jason at cornsyrup dot org
2012-07-20 23:11 ` [Bug c++/54059] " jason at cornsyrup dot org
2012-07-20 23:12 ` pinskia at gcc dot gnu.org
2012-07-20 23:14 ` redi at gcc dot gnu.org
2012-07-20 23:17 ` jason at cornsyrup dot org

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).