public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28728]  New: function declaration inside function
@ 2006-08-14 20:07 mceier at gmail dot com
  2006-08-14 20:39 ` [Bug c++/28728] " pinskia at gcc dot gnu dot org
  2006-08-14 20:43 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: mceier at gmail dot com @ 2006-08-14 20:07 UTC (permalink / raw)
  To: gcc-bugs

With GCC it is possible to declare function inside other function. I think the
code below should not compile because of ambiguity - compiler can create a
variable ( test ) and call constructor of class Test ( Test::Test() ) or
interpret this as function declaration as GCC does ( which is invalid because
of place where the function was declared - I'm not a C++ expert, so I'm asking
if it is valid to declare a function inside other function and use it as all
normal functions ?? )
Sorry for my english

The Code:

#include <cstdio>
class Test {
public:
        Test(void);
        void SomeFunction(void) const;
        ~Test(void);
};
Test::Test(void) { printf("%s\n",__FUNCTION__); }
void Test::SomeFunction(void) const { printf("%s\n",__FUNCTION__); }
Test::~Test(void) { printf("%s\n",__FUNCTION__); }
int main(void) {
        // Declaring function in global scope, instead of variable of type
Test:
        Test test() ;
        test().SomeFunction();
        return 0;
}
// Defining function which declaration is inside main:
Test test() { return Test(); }


-- 
           Summary: function declaration inside function
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mceier at gmail dot com


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


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

* [Bug c++/28728] function declaration inside function
  2006-08-14 20:07 [Bug c++/28728] New: function declaration inside function mceier at gmail dot com
@ 2006-08-14 20:39 ` pinskia at gcc dot gnu dot org
  2006-08-14 20:43 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-14 20:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-08-14 20:39 -------
Test test() ;
does define a function that is extern to the current function.
It is one of the ambious parts of C++ that the C++ standard resolves to a
function prototype.


-- 


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


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

* [Bug c++/28728] function declaration inside function
  2006-08-14 20:07 [Bug c++/28728] New: function declaration inside function mceier at gmail dot com
  2006-08-14 20:39 ` [Bug c++/28728] " pinskia at gcc dot gnu dot org
@ 2006-08-14 20:43 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-14 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-08-14 20:42 -------
Invalid as explained.

*** This bug has been marked as a duplicate of 18000 ***


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-08-14 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-14 20:07 [Bug c++/28728] New: function declaration inside function mceier at gmail dot com
2006-08-14 20:39 ` [Bug c++/28728] " pinskia at gcc dot gnu dot org
2006-08-14 20:43 ` 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).