This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

-Wmaybe-uninitialized


The following was posted on comp.lanc.c++ by Ralf Goertz:
https://groups.google.com/d/msg/comp.lang.c++/Tb5Ir3A71nw/szKUC5j8AQAJ

#include <iostream>

int main(int argc, char *argv[])
{
  int x;
  if(argc > 1) x = 1;

  std::cout << x << std::endl;
}

Despite the description of -Wmaybe-uninitialized, even with optimizing compilation, neither gcc 8.2.1 nor gcc 7.3.1 report the expected warning (with "c++ -Wall -O{1,3}").

Are we missing something?
Thanks in advance.

PS.
BTW the trivial C translation behaves the same with "cc -Wall -O{1,3}":

#include <stdio.h>

int main(int argc, char *argv[])
{
  int x;
  if(argc > 1) x = 1;

  printf("%d\n", x);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]