public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58063] New: default arguments evaluated twice per call
@ 2013-08-02 20:38 plokinom at gmail dot com
  2013-08-03 20:40 ` [Bug c++/58063] " paolo.carlini at oracle dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: plokinom at gmail dot com @ 2013-08-02 20:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58063
           Summary: default arguments evaluated twice per call
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: plokinom at gmail dot com

% cat try.cc
#include <iostream>

void f(bool x = !(std::cout << "hi!\n")) {
    std::cout << x << '\n';
}

int main() {
    f();
}

% g++ try.cc
% ./a.out 
hi!
hi!
0

My question: Why is the default argument evaluated twice for each call to f()?

Is this allowed by the standard or a bug in g++?


% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/mauke/usr/local/libexec/gcc/i686-pc-linux-gnu/4.8.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.8.1/configure --prefix=/home/mauke/usr/local
--with-arch=native --with-tune=native --enable-__cxa_atexit
--enable-languages=c,c++,go --disable-nls
Thread model: posix
gcc version 4.8.1 (GCC)


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

end of thread, other threads:[~2015-08-18 14:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-02 20:38 [Bug c++/58063] New: default arguments evaluated twice per call plokinom at gmail dot com
2013-08-03 20:40 ` [Bug c++/58063] " paolo.carlini at oracle dot com
2013-08-03 20:48 ` daniel.kruegler at googlemail dot com
2013-08-03 20:58 ` paolo.carlini at oracle dot com
2013-08-03 21:23 ` daniel.kruegler at googlemail dot com
2013-08-03 21:34 ` daniel.kruegler at googlemail dot com
2013-08-04 12:11 ` fanael4 at gmail dot com
2013-08-04 12:22 ` paolo.carlini at oracle dot com
2015-06-14 18:02 ` plokinom at gmail dot com
2015-06-16 19:29 ` jason at gcc dot gnu.org
2015-06-17 14:33 ` jason at gcc dot gnu.org
2015-06-21  9:06 ` ville.voutilainen at gmail dot com
2015-08-18 14:44 ` jason at gcc dot gnu.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).