I met a "strange" thing...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

by pure chance, during a copy+paste editing operation of a source code,
I ended up inadvertently with a code line like the following:

                         int * x = int();

Well, this code HAD BEEN COMPILED by g++ 4.8.3, and I cannot figure out its meaning (from the compiler's point of view).

Here is a code sample of what happened to me:

int main()
 {
  int * x = int();  // compiled
  *x = 888;         // compiled
  std::cout << *x << std::endl;  // compiled, but segfault at execution
  // I can understand the last event ...
 }

What is the semantic of a kind of "default constructor of int" assigned to a pointer?

Thanks for your attention.

                       G. Servizi





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux