[Bug c++/58063] New: default arguments evaluated twice per call

2013-08-02 Thread plokinom at gmail dot com
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 

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)


[Bug c/64175] New: #pragma GCC diagnostic pop doesn't re-disable -Wnested-externs

2014-12-03 Thread plokinom at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64175

Bug ID: 64175
   Summary: #pragma GCC diagnostic pop doesn't re-disable
-Wnested-externs
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: plokinom at gmail dot com

$ cat foo.c
#pragma GCC diagnostic warning "-Wnested-externs"
#pragma GCC diagnostic pop
static void bar(void) { extern int main(void); }
int main(void) { return 0; }

$ gcc foo.c
foo.c: In function ‘bar’:
foo.c:3:1: warning: nested extern declaration of ‘main’ [-Wnested-externs]
 static void bar(void) { extern int main(void); }
 ^

I think this is a bug because according to the documentation "If a 'pop' has no
matching 'push', the command-line options are restored" and there is no
-Wnested-externs on the command line, so gcc shouldn't warn.

[Bug c++/58063] default arguments evaluated twice per call

2015-06-14 Thread plokinom at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58063

--- Comment #12 from plokinom at gmail dot com ---
I can confirm this still happens with g++ 5.1.0.