public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48185] New: if(struct ...)
@ 2011-03-18 15:58 lisp2d at lisp2d dot net
  2011-03-18 16:08 ` [Bug c++/48185] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lisp2d at lisp2d dot net @ 2011-03-18 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: if(struct ...)
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lisp2d@lisp2d.net


Variable definition in structure if() can't receive type struct.

if(struct passwd*pwd(getpwuid(...)))return;

error: expected primary-expression before ‘struct’
error: expected ‘)’ before ‘struct’


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

* [Bug c++/48185] if(struct ...)
  2011-03-18 15:58 [Bug c++/48185] New: if(struct ...) lisp2d at lisp2d dot net
@ 2011-03-18 16:08 ` rguenth at gcc dot gnu.org
  2011-03-18 17:21 ` lisp2d at lisp2d dot net
  2011-03-18 17:46 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-18 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

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

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-18 16:02:01 UTC ---
That is neither C nor C++.


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

* [Bug c++/48185] if(struct ...)
  2011-03-18 15:58 [Bug c++/48185] New: if(struct ...) lisp2d at lisp2d dot net
  2011-03-18 16:08 ` [Bug c++/48185] " rguenth at gcc dot gnu.org
@ 2011-03-18 17:21 ` lisp2d at lisp2d dot net
  2011-03-18 17:46 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: lisp2d at lisp2d dot net @ 2011-03-18 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Lisp2D <lisp2d at lisp2d dot net> 2011-03-18 17:15:23 UTC ---
Code

{ struct passwd*pwd(getpwuid(...));
  if(pwd)return true;}

is still compiled.

Code

if(struct passwd*pwd=getpwuid(...))return;

compiled too.

But 

if(struct passwd*pwd(getpwuid(...)))return;

will not.

Who is right?


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

* [Bug c++/48185] if(struct ...)
  2011-03-18 15:58 [Bug c++/48185] New: if(struct ...) lisp2d at lisp2d dot net
  2011-03-18 16:08 ` [Bug c++/48185] " rguenth at gcc dot gnu.org
  2011-03-18 17:21 ` lisp2d at lisp2d dot net
@ 2011-03-18 17:46 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-18 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-18 17:27:43 UTC ---
G++ is right

a declaration in a selection-statement (if or switch) must be of the form:
  if ( type-specifier id = initializer )
or in C++0x:
  if ( type-specifier id { init } )

See 6.4 in the C++ standard


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

end of thread, other threads:[~2011-03-18 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 15:58 [Bug c++/48185] New: if(struct ...) lisp2d at lisp2d dot net
2011-03-18 16:08 ` [Bug c++/48185] " rguenth at gcc dot gnu.org
2011-03-18 17:21 ` lisp2d at lisp2d dot net
2011-03-18 17:46 ` redi at gcc dot gnu.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).