public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41786]  New: misparsing an object declaration - parameter may not have variably modified type
@ 2009-10-21 19:42 jarausch at igpm dot rwth-aachen dot de
  2009-10-21 19:49 ` [Bug c++/41786] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jarausch at igpm dot rwth-aachen dot de @ 2009-10-21 19:42 UTC (permalink / raw)
  To: gcc-bugs

The declaration 
form proj (space(V[i]), V_new_i, "mass");
of an object 'proj' of class 'form' is not recognized,
see below

#include <vector>
using std::vector;
#include <string>

struct space_component;
struct const_space_component;

template <class T>
class smart_pointer {
public:

// allocators:

        smart_pointer (T* p = 0);
        smart_pointer (const smart_pointer&);
        ~smart_pointer ();
        smart_pointer& operator= (const smart_pointer&);

// accessors:

        const T* pointer    () const;
        const T& data       () const;
        const T* operator-> () const;
        const T& operator*  () const;

// modifiers:

        T* pointer ();
        T* operator-> ();
        T& data ();
        T& operator* ();

// implementation:

};

typedef int basis;

class spacerep {
public:
  typedef std::vector<basis>::size_type  size_type;
  spacerep();
};


class space : public smart_pointer<spacerep> {
public:
// typdefs:

    typedef spacerep::size_type size_type;

// allocator/deallocator:

    space ();
    space(const const_space_component&);

    space_component operator [] (size_type i_comp);
    const_space_component operator [] (size_type i_comp) const;
};

struct space_component {
    typedef space::size_type size_type;
    space_component();
    space_component(space& V, size_type i);
};
struct const_space_component {
    typedef space::size_type size_type;
    const_space_component();
    const_space_component(const space_component&);
};

class form {
public :
    form ();
    form (const space& X, const space& Y, const std::string& op_name, 
        bool locked_boundaries=false);

};

int main() {
            space V, V_new_i;
            int i=1;
            form proj (space(V[i]), V_new_i, "mass");
/* error: parameter may not have variably modified type 
  'space [(((long unsigned int)(((long int)i) + -0x00000000000000001)) + 1)]'
*/

}


-- 
           Summary: misparsing an object declaration - parameter may not
                    have variably modified type
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jarausch at igpm dot rwth-aachen dot de
 GCC build triplet: x86-64
  GCC host triplet: x86-64
GCC target triplet: x86-64


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


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

* [Bug c++/41786] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
@ 2009-10-21 19:49 ` pinskia at gcc dot gnu dot org
  2009-10-22 10:35 ` jarausch at igpm dot rwth-aachen dot de
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-10-21 19:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-10-21 19:49 -------
I don't think this is misparsing this at all.  This is one place in the C++
standard that says it should be parsed as a function declaration rather than a
variable declaration to resolve an ambiguous between those two.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|misparsing an object        |misparsing an object
                   |declaration - parameter may |declaration - parameter may
                   |not have variably modified  |not have variably modified
                   |type                        |type


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


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

* [Bug c++/41786] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
  2009-10-21 19:49 ` [Bug c++/41786] " pinskia at gcc dot gnu dot org
@ 2009-10-22 10:35 ` jarausch at igpm dot rwth-aachen dot de
  2010-03-09 22:33 ` [Bug c++/41786] [4.4/4.5 regression] " jason at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jarausch at igpm dot rwth-aachen dot de @ 2009-10-22 10:35 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2394 bytes --]



------- Comment #2 from jarausch at igpm dot rwth-aachen dot de  2009-10-22 10:35 -------
(In reply to comment #1)
> I don't think this is misparsing this at all.  This is one place in the C++
> standard that says it should be parsed as a function declaration rather than a
> variable declaration to resolve an ambiguous between those two.
> 


There are different opinions about that.
The current Comeau compiler does accept the code.

Here an answer James Kanze on the news group comp.lang.c++

First, there is absolutely no way that proj can be interpreted
as a function declaration; the string literal prevents that,
regardless of anything else.  Second, if "space" is the
name of a type (as it is in your code), »space(V[i])« is a
function declaration in any context that allows function
declarations.  The only contexts which allow declarations
other than at the statement level, however, is as part of other
declarations; the only context in which a function declaration
can be followed by a comma is as a parameter in another function
declaration.  Since in this case, the string literal means that
this statement cannot be a function declaration, »space(V[i])«
cannot be a parameter declaration, and thus, cannot be a
function declaration.  There's no ambiguity.  (This is a
difficult parse, however, since the interpretation here depends
on context.  In something like:
    form proj( space(V[i]) );
»space(V[i])« is a function declaration, and the entire
statement is a function declaration, because there is nothing
which makes it illegal as a function declaration.)

I do remember earlier versions of g++ (2.95.2?) having problems
with this; they didn't consider context to the right of the
expression when making the decision, so something like:
    form proj( space(V[i]), "abc" );
would fail to compile, treating »space(V[i])« as a function
declaration, whereas:
    form proj( "abc", space(V[i]) );
worked, since the preceding string literal had removed the
ambiguity of the context.  Later versions of g++ fixed this.  It
sounds to me like they've reintroduced the bug, and that someone
has decided (on what grounds, I don't know), that it's not a
bug, but a feature.

This is probably a shorter test case:

struct A { A(int, char const*); };
int main() {
  int i = 0, *b = &i;
  A a(int(b[i]), "hello");
}


-- 


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
  2009-10-21 19:49 ` [Bug c++/41786] " pinskia at gcc dot gnu dot org
  2009-10-22 10:35 ` jarausch at igpm dot rwth-aachen dot de
@ 2010-03-09 22:33 ` jason at gcc dot gnu dot org
  2010-03-09 22:33 ` jason at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-03-09 22:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jason at gcc dot gnu dot org  2010-03-09 22:32 -------
I agree with James Kanze's analysis.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-09 22:32:49
               date|                            |
            Summary|misparsing an object        |[4.4/4.5 regression]
                   |declaration - parameter may |misparsing an object
                   |not have variably modified  |declaration - parameter may
                   |type                        |not have variably modified
                   |                            |type


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (2 preceding siblings ...)
  2010-03-09 22:33 ` [Bug c++/41786] [4.4/4.5 regression] " jason at gcc dot gnu dot org
@ 2010-03-09 22:33 ` jason at gcc dot gnu dot org
  2010-03-09 22:43 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-03-09 22:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-03-09 22:32:49         |2010-03-09 22:33:00
               date|                            |


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (3 preceding siblings ...)
  2010-03-09 22:33 ` jason at gcc dot gnu dot org
@ 2010-03-09 22:43 ` pinskia at gcc dot gnu dot org
  2010-03-10 16:24 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-09 22:43 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.4


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (4 preceding siblings ...)
  2010-03-09 22:43 ` pinskia at gcc dot gnu dot org
@ 2010-03-10 16:24 ` rguenth at gcc dot gnu dot org
  2010-03-30 21:20 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-10 16:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.4.3
      Known to work|                            |4.3.4
           Priority|P3                          |P2


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (5 preceding siblings ...)
  2010-03-10 16:24 ` rguenth at gcc dot gnu dot org
@ 2010-03-30 21:20 ` jason at gcc dot gnu dot org
  2010-03-30 21:21 ` jason at gcc dot gnu dot org
  2010-03-30 21:23 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-03-30 21:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2010-03-30 21:19 -------
Subject: Bug 41786

Author: jason
Date: Tue Mar 30 21:19:23 2010
New Revision: 157838

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157838
Log:
        PR c++/41185
        PR c++/41786
        * parser.c (cp_parser_direct_declarator): Don't allow VLAs in
        function parameter context.  Don't print an error if parsing
        tentatively.

Added:
    trunk/gcc/testsuite/g++.dg/parse/ambig5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/varmod1.C


-- 


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (6 preceding siblings ...)
  2010-03-30 21:20 ` jason at gcc dot gnu dot org
@ 2010-03-30 21:21 ` jason at gcc dot gnu dot org
  2010-03-30 21:23 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-03-30 21:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2010-03-30 21:21 -------
Subject: Bug 41786

Author: jason
Date: Tue Mar 30 21:20:58 2010
New Revision: 157839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157839
Log:
        PR c++/41185
        PR c++/41786
        * parser.c (cp_parser_direct_declarator): Don't allow VLAs in
        function parameter context.  Don't print an error if parsing
        tentatively.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/ambig5.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/parser.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/varmod1.C


-- 


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


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

* [Bug c++/41786] [4.4/4.5 regression] misparsing an object declaration - parameter may not have variably modified type
  2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
                   ` (7 preceding siblings ...)
  2010-03-30 21:21 ` jason at gcc dot gnu dot org
@ 2010-03-30 21:23 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-03-30 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2010-03-30 21:22 -------
Fixed for 4.4.4 and 4.5.0.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2010-03-30 21:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-21 19:42 [Bug c++/41786] New: misparsing an object declaration - parameter may not have variably modified type jarausch at igpm dot rwth-aachen dot de
2009-10-21 19:49 ` [Bug c++/41786] " pinskia at gcc dot gnu dot org
2009-10-22 10:35 ` jarausch at igpm dot rwth-aachen dot de
2010-03-09 22:33 ` [Bug c++/41786] [4.4/4.5 regression] " jason at gcc dot gnu dot org
2010-03-09 22:33 ` jason at gcc dot gnu dot org
2010-03-09 22:43 ` pinskia at gcc dot gnu dot org
2010-03-10 16:24 ` rguenth at gcc dot gnu dot org
2010-03-30 21:20 ` jason at gcc dot gnu dot org
2010-03-30 21:21 ` jason at gcc dot gnu dot org
2010-03-30 21:23 ` jason 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).