public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36696]  New: Default constructor instance definition with empty argument list quietly ignored
@ 2008-07-02 14:25 mike dot allen at facsim dot org
  2008-07-02 14:42 ` [Bug c++/36696] " mike dot allen at facsim dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mike dot allen at facsim dot org @ 2008-07-02 14:25 UTC (permalink / raw)
  To: gcc-bugs

Compile following with -Wall:

#include <iostream>

class Raii
{
public:
    Raii () throw ()
    {
        std::cout << "Raii::Raii () called..." << std::endl;
    }
public:
    ~Raii () throw ()
    {
        std::cout << "Raii::~Raii () called..." << std:: endl;
    }
};

int main (int /*argc*/, char** /*argv*/)
{
    Raii raii ();
    std::cout << "Inside main ()..." << std::endl;
    return 0;
}

This compiles with no errors.  When the result is executed, you get the
following output:

Inside main ()...

And that's all.  The compiler quietly ignored the declaration of an Raii
instance with an empty argument list.  No warnings, no errors, nothing.

If the empty argument list is removed, that is, if you have:

#include <iostream>

class Raii
{
public:
    Raii () throw ()
    {
        std::cout << "Raii::Raii () called..." << std::endl;
    }
public:
    ~Raii () throw ()
    {
        std::cout << "Raii::~Raii () called..." << std:: endl;
    }
};

int main (int /*argc*/, char** /*argv*/)
{
    Raii raii;
    std::cout << "Inside main ()..." << std::endl;
    return 0;
}

Then you get the expected output:

Raii::Raii () called...
Inside main ()...
Raii::~Raii () called...

Is this correct behavior?

g++ -v:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)


-- 
           Summary: Default constructor instance definition with empty
                    argument list quietly ignored
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mike dot allen at facsim dot org
GCC target triplet: i486-linux-gnu


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


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

* [Bug c++/36696] Default constructor instance definition with empty argument list quietly ignored
  2008-07-02 14:25 [Bug c++/36696] New: Default constructor instance definition with empty argument list quietly ignored mike dot allen at facsim dot org
@ 2008-07-02 14:42 ` mike dot allen at facsim dot org
  2008-07-02 21:10 ` dseketel at redhat dot com
  2008-07-02 21:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mike dot allen at facsim dot org @ 2008-07-02 14:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mike dot allen at facsim dot org  2008-07-02 14:41 -------
Is the line:

Raii raii();

being interpreted by the compiler as the declaration of a function that takes
no arguments and returns a Raii instance?


-- 


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


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

* [Bug c++/36696] Default constructor instance definition with empty argument list quietly ignored
  2008-07-02 14:25 [Bug c++/36696] New: Default constructor instance definition with empty argument list quietly ignored mike dot allen at facsim dot org
  2008-07-02 14:42 ` [Bug c++/36696] " mike dot allen at facsim dot org
@ 2008-07-02 21:10 ` dseketel at redhat dot com
  2008-07-02 21:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: dseketel at redhat dot com @ 2008-07-02 21:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dseketel at redhat dot com  2008-07-02 21:09 -------
Yes, foo bar (); is indeed the declaration of a function bar of type foo that
takes no arguments in parameter.

I believe gcc is right there.


-- 

dseketel at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dseketel at redhat dot com


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


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

* [Bug c++/36696] Default constructor instance definition with empty argument list quietly ignored
  2008-07-02 14:25 [Bug c++/36696] New: Default constructor instance definition with empty argument list quietly ignored mike dot allen at facsim dot org
  2008-07-02 14:42 ` [Bug c++/36696] " mike dot allen at facsim dot org
  2008-07-02 21:10 ` dseketel at redhat dot com
@ 2008-07-02 21:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-02 21:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-07-02 21:16 -------
This is an ambiguous in the C++ standard that is resolved via making it a
function declaration.
That is:
    Raii raii ();

Is declaring a function, raii, that returns a Raii type.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-07-02 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-02 14:25 [Bug c++/36696] New: Default constructor instance definition with empty argument list quietly ignored mike dot allen at facsim dot org
2008-07-02 14:42 ` [Bug c++/36696] " mike dot allen at facsim dot org
2008-07-02 21:10 ` dseketel at redhat dot com
2008-07-02 21:16 ` pinskia at gcc dot gnu 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).