public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12615] New: initializer syntax for PAD structs gives parse error
@ 2003-10-14 19:37 gcc-bugzilla at gcc dot gnu dot org
  2003-10-14 19:47 ` [Bug c++/12615] [3.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2003-10-14 19:37 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: initializer syntax for PAD structs gives parse error
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bruno at clisp dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


The following snippet of code used to compile with g++ 3.2.2, but now
gives an error.

============================ bug1.cc ===================================
struct object
{
  unsigned long one_o;
  unsigned int allocstamp;
};
void gc_mark (object obj)
{
  object vorg = (object) { one_o: 0, allocstamp: 0 };
}
========================================================================
$ g++ -O -c bug1.cc
bug1.cc: In function `void gc_mark(object)':
bug1.cc:8: error: `object' has no non-static data member named
`object::one_o'
bug1.cc:8: error: too many initializers for `object'

Environment:
System: Linux honolulu.ilog.fr 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686 unknown unknown GNU/Linux
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.3.1/configure --prefix=/home/haible/gnu/inst-gcc/3.3.1 --enable-shared --enable-threads=posix --enable-long-long --enable-__cxa_atexit --enable-languages=c,c++,ada,f77,objc,java --with-system-zlib

How-To-Repeat:

See above,
------- Additional Comments From bruno at clisp dot org  2003-10-14 19:37 -------
Fix:

unknown.


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
@ 2003-10-14 19:47 ` pinskia at gcc dot gnu dot org
  2003-10-14 19:54 ` gdr at integrable-solutions dot net
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-14 19:47 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2003-10-14 19:47:39
               date|                            |
            Summary|initializer syntax for PAD  |[3.3 Regression] initializer
                   |structs gives parse error   |syntax for PAD structs gives
                   |                            |parse error
   Target Milestone|---                         |3.3.3


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-14 19:47 -------
: Search converges between 2003-04-29-3.3 (#113) and 2003-04-30-3.3 (#114).
Already fixed on the mainline: Search converges between 2003-06-03-trunk (#302) and 2003-06
-04-trunk (#303).


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
  2003-10-14 19:47 ` [Bug c++/12615] [3.3 Regression] " pinskia at gcc dot gnu dot org
@ 2003-10-14 19:54 ` gdr at integrable-solutions dot net
  2003-10-14 21:38   ` Joseph S. Myers
  2003-10-14 20:13 ` schwab at suse dot de
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-14 19:54 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-14 19:54 -------
Subject: Re:  [3.3 Regression] initializer syntax for PAD structs gives parse error

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

|            Keywords|                            |rejects-valid

I do not agree this is reject-valid.  

  object vorg = (object) { one_o: 0, allocstamp: 0 };

while valid C99, is invalid C++.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
  2003-10-14 19:47 ` [Bug c++/12615] [3.3 Regression] " pinskia at gcc dot gnu dot org
  2003-10-14 19:54 ` gdr at integrable-solutions dot net
@ 2003-10-14 20:13 ` schwab at suse dot de
  2003-10-14 20:40 ` gdr at integrable-solutions dot net
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: schwab at suse dot de @ 2003-10-14 20:13 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From schwab at suse dot de  2003-10-14 20:13 -------
It's not even valid C99, only GNU C.


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-10-14 20:13 ` schwab at suse dot de
@ 2003-10-14 20:40 ` gdr at integrable-solutions dot net
  2003-10-14 20:46 ` bruno at clisp dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-14 20:40 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-14 20:40 -------
Subject: Re:  [3.3 Regression] initializer syntax for PAD structs gives parse error

"schwab at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| It's not even valid C99, only GNU C.

Thanks!  I propose to resolve this PR as INVALID.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2003-10-14 20:40 ` gdr at integrable-solutions dot net
@ 2003-10-14 20:46 ` bruno at clisp dot org
  2003-10-14 21:38 ` [Bug c++/12615] [3.3 Regression] initializer syntax for POD " jsm at polyomino dot org dot uk
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: bruno at clisp dot org @ 2003-10-14 20:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bruno at clisp dot org  2003-10-14 20:46 -------
Andreas, right. The GCC documentation says that this GCC extension documented under 
the name "Compound Literals" is supported as part of C99. But in ISO C99 only the bracket 
expression without the preceding cast would be a valid initializer. 
 
Nevertheless, the GCC documentation also says that "These extensions are available in C 
and Objective-C.  Most of them are also available in C++." IMO this means that g++ should 
support it.


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

* Re: [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 19:54 ` gdr at integrable-solutions dot net
@ 2003-10-14 21:38   ` Joseph S. Myers
  2003-10-14 22:10     ` Gabriel Dos Reis
  0 siblings, 1 reply; 17+ messages in thread
From: Joseph S. Myers @ 2003-10-14 21:38 UTC (permalink / raw)
  To: gdr at integrable-solutions dot net; +Cc: gcc-bugs

On Tue, 14 Oct 2003, gdr at integrable-solutions dot net wrote:

>   object vorg = (object) { one_o: 0, allocstamp: 0 };
> 
> while valid C99, is invalid C++.

There are two extensions to C++ in play here:

* Compound literals (documented as supported as an extension in C++).

* Designated initializers, documented as unimplemented in GNU C++.  This 
example in fact uses the obsolete GNU syntax rather than the standard C99 
one.  I'd like to deprecate that obsolete syntax properly - the obstacle 
to doing so is deployed glibc headers that use the obsolete syntax in 
macros on the basis that (some version of) G++ does in fact support 
designated initializers, but only with the old and not the C99 syntax!

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2003-10-14 20:46 ` bruno at clisp dot org
@ 2003-10-14 21:38 ` jsm at polyomino dot org dot uk
  2003-10-14 21:40 ` gdr at integrable-solutions dot net
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: jsm at polyomino dot org dot uk @ 2003-10-14 21:38 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From jsm at polyomino dot org dot uk  2003-10-14 21:38 -------
Subject: Re:  [3.3 Regression] initializer syntax for PAD
 structs gives parse error

On Tue, 14 Oct 2003, gdr at integrable-solutions dot net wrote:

>   object vorg = (object) { one_o: 0, allocstamp: 0 };
> 
> while valid C99, is invalid C++.

There are two extensions to C++ in play here:

* Compound literals (documented as supported as an extension in C++).

* Designated initializers, documented as unimplemented in GNU C++.  This 
example in fact uses the obsolete GNU syntax rather than the standard C99 
one.  I'd like to deprecate that obsolete syntax properly - the obstacle 
to doing so is deployed glibc headers that use the obsolete syntax in 
macros on the basis that (some version of) G++ does in fact support 
designated initializers, but only with the old and not the C99 syntax!


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2003-10-14 21:38 ` [Bug c++/12615] [3.3 Regression] initializer syntax for POD " jsm at polyomino dot org dot uk
@ 2003-10-14 21:40 ` gdr at integrable-solutions dot net
  2003-10-15 10:44 ` bruno at clisp dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-14 21:40 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-14 21:40 -------
Subject: Re:  [3.3 Regression] initializer syntax for PAD structs gives parse error

"bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Nevertheless, the GCC documentation also says that "These extensions are available in C 
| and Objective-C.  Most of them are also available in C++." IMO this means that g++ should 
| support it.

IIRC the documentation does not list it as specifically supported by
the C++ front-end.  It is not valid C++, nor valid C99.  There is a
standard way to express an equivalent construct.  I  would strongly
suggest you use it. 

-- Gaby


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

* Re: [Bug c++/12615] [3.3 Regression] initializer syntax for PAD structs gives parse error
  2003-10-14 21:38   ` Joseph S. Myers
@ 2003-10-14 22:10     ` Gabriel Dos Reis
  0 siblings, 0 replies; 17+ messages in thread
From: Gabriel Dos Reis @ 2003-10-14 22:10 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-bugs

"Joseph S. Myers" <jsm@polyomino.org.uk> writes:

| On Tue, 14 Oct 2003, gdr at integrable-solutions dot net wrote:
| 
| >   object vorg = (object) { one_o: 0, allocstamp: 0 };
| > 
| > while valid C99, is invalid C++.
| 
| There are two extensions to C++ in play here:
| 
| * Compound literals (documented as supported as an extension in C++).

FWIW, there is a proposal to add generalized initializer list to C++,
that in limits will support C99 compound literals (but without
designated initializers)

  http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1509.pdf

| * Designated initializers, documented as unimplemented in GNU C++.  This 
| example in fact uses the obsolete GNU syntax rather than the standard C99 
| one.  I'd like to deprecate that obsolete syntax properly

I second the deprecation initiative.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2003-10-14 21:40 ` gdr at integrable-solutions dot net
@ 2003-10-15 10:44 ` bruno at clisp dot org
  2003-10-15 11:20 ` gdr at integrable-solutions dot net
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: bruno at clisp dot org @ 2003-10-15 10:44 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bruno at clisp dot org  2003-10-15 10:44 -------
Gabriel dos Reis writes: 
> There is a standard way to express an equivalent construct.  I  would strongly 
> suggest you use it. 
 
The problem with this is that it is not a syntax which is valid in initializers _and_ 
expressions. I'd need to write 
 
void gc_mark (object obj) 
{ 
  // Initializer syntax 
  object a = { one_o: 0, allocstamp: 0 }; 
  // Expression syntax 
  object b; b = (object) { one_o: 0, allocstamp: 0 }; 
} 
 
This means that for all of my macros returning a constructed 'object', I'd need 
two variants: one for use in initializers and one for use in expressions. This is 
not reasonable. 
 
Can't you give me a syntax which 
  - works both in expressions and initializers, 
  - preferrably also works the same way in GNU C?


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2003-10-15 10:44 ` bruno at clisp dot org
@ 2003-10-15 11:20 ` gdr at integrable-solutions dot net
  2003-10-15 11:49 ` bruno at clisp dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-15 11:20 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-15 11:20 -------
Subject: Re:  [3.3 Regression] initializer syntax for POD structs gives parse error

"bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Gabriel dos Reis writes: 
| > There is a standard way to express an equivalent construct.  I  would strongly 
| > suggest you use it. 
|  
| The problem with this is that it is not a syntax which is valid in
| initializers _and_  expressions. I'd need to write 

The C99 standard syntax works in both cases

The syntax you used is documented as non-supported in g++.  So this
is a C++ bug.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2003-10-15 11:20 ` gdr at integrable-solutions dot net
@ 2003-10-15 11:49 ` bruno at clisp dot org
  2003-10-15 16:23 ` gdr at integrable-solutions dot net
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: bruno at clisp dot org @ 2003-10-15 11:49 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bruno at clisp dot org  2003-10-15 11:49 -------
Gabriel dos Reis writes: 
> | The problem with this is that it is not a syntax which is valid in 
> | initializers _and_  expressions. I'd need to write  
> 
> The C99 standard syntax works in both cases 
 
No it doesn't. None of the possible syntaxes work both in initializer position 
and in expression position, with g++ 3.3.1: 
 
===================================================== 
struct object 
{ 
  unsigned long one_o; 
  unsigned int allocstamp; 
}; 
typedef struct object object; 
void gc_mark (object obj) 
{ 
  // Old GNU designated initializer syntax, without cast. 
  { 
    // As initializer. 
    object a = { one_o: 0, allocstamp: 0 }; 
    // As expression - syntax error in gcc and g++. 
    object b; b = { one_o: 0, allocstamp: 0 }; 
  } 
  // Old GNU designated initializer syntax, with cast. 
  { 
    // As initializer - syntax error in g++. 
    object a = (object) { one_o: 0, allocstamp: 0 }; 
    // As expression. 
    object b; b = (object) { one_o: 0, allocstamp: 0 }; 
  } 
  // New ISO C 99 designated initializer syntax, without cast. 
  { 
    // As initializer - syntax error in g++. 
    object a = { .one_o = 0, .allocstamp = 0 }; 
    // As expression - syntax error in gcc and g++. 
    object b; b = { .one_o = 0, .allocstamp = 0 }; 
  } 
  // New ISO C 99 designated initializer syntax, with cast. 
  { 
    // As initializer - syntax error in g++. 
    object a = (object) { .one_o = 0, .allocstamp = 0 }; 
    // As expression - syntax error in g++. 
    object b; b = (object) { .one_o = 0, .allocstamp = 0 }; 
  } 
} 
========================================================= 
 
Which of the four syntaxes you recommend me to choose?


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2003-10-15 11:49 ` bruno at clisp dot org
@ 2003-10-15 16:23 ` gdr at integrable-solutions dot net
  2003-10-15 18:43 ` bruno at clisp dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-15 16:23 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-15 16:23 -------
Subject: Re:  [3.3 Regression] initializer syntax for POD structs gives parse error

"bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org> writes:

[...]

|   // New ISO C 99 designated initializer syntax, without cast. 
|   { 
|     // As initializer - syntax error in g++. 
|     object a = { .one_o = 0, .allocstamp = 0 }; 
|     // As expression - syntax error in gcc and g++. 
|     object b; b = { .one_o = 0, .allocstamp = 0 }; 
|   } 
|   // New ISO C 99 designated initializer syntax, with cast. 
|   { 
|     // As initializer - syntax error in g++. 
|     object a = (object) { .one_o = 0, .allocstamp = 0 }; 
|     // As expression - syntax error in g++. 
|     object b; b = (object) { .one_o = 0, .allocstamp = 0 }; 
|   } 
| } 
| ========================================================= 
|  
| Which of the four syntaxes you recommend me to choose?


   object a = { 0, 0 }; // for C, C++

for initialization.

   object a;
   a = (object) { 0, 0 }; // for C, soon for C++

Fill a PR and put me on the CC list.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2003-10-15 16:23 ` gdr at integrable-solutions dot net
@ 2003-10-15 18:43 ` bruno at clisp dot org
  2003-10-18 11:32 ` gdr at integrable-solutions dot net
  2003-10-18 15:21 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 17+ messages in thread
From: bruno at clisp dot org @ 2003-10-15 18:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bruno at clisp dot org  2003-10-15 18:43 -------
Gabriel dos Reis writes: 
>   object a = { 0, 0 }; // for initialization. 
>   object a; a = (object) { 0, 0 }; 
 
This recommendation, to use different syntax for initialization than for 
assignment, goes against the ISO C++ grammar. The allowed syntax 
for initializers is: 
 
  initializer: 
          = initializer-clause 
          ( expression-list ) 
  initializer-clause: 
          assignment-expression 
          { initializer-list ,opt } 
          { } 
  expression-list: 
          assignment-expression 
          expression-list , assignment-expression 
 
This means that g++ should grok any "assignment-expression" as initializer. 
"assignment-expression" occurs in a few other places in the grammar as 
well: throw statements, default values for optional parameters of functions, 
general expressions. In all these cases, the GNU "Compound Literal" extension 
      ((object) { 0, 0 }) 
is supported. In the initializer case, g++ 3.3.1 gives an error. Which means, 
g++ 3.3.1 has an inconsistent definition of what is an "assignment-expression". 
 
Look here: func1, func2, func3 are accepted without error. func4 gives an error. 
======================================================= 
struct object 
{ 
  unsigned long one_o; 
  unsigned int allocstamp; 
}; 
typedef struct object object; 
 
//#define NULL_OBJECT ((object) { .one_o = 0, .allocstamp = 0 }) 
//#define NULL_OBJECT ((object) { one_o: 0, allocstamp: 0 }) 
#define NULL_OBJECT ((object) { 0, 0 }) 
 
// throw-expression: 
//       throw assignment-expression_opt 
void func1 () { throw NULL_OBJECT; } 
 
// expression: 
//       assignment-expression 
void func2 (object a) { a = NULL_OBJECT; } 
 
// parameter-declaration: 
//       decl-specifier-seq declarator = assignment-expression 
void func3 (object a = NULL_OBJECT) {} 
 
// initializer: 
//       = initializer-clause 
//       ( expression-list ) 
// initializer-clause: 
//       assignment-expression 
void func4 () { object a = NULL_OBJECT; } 
=======================================================


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2003-10-15 18:43 ` bruno at clisp dot org
@ 2003-10-18 11:32 ` gdr at integrable-solutions dot net
  2003-10-18 15:21 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-10-18 11:32 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gdr at integrable-solutions dot net  2003-10-18 11:28 -------
Subject: Re:  [3.3 Regression] initializer syntax for POD structs gives parse error

"bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Gabriel dos Reis writes: 
| >   object a = { 0, 0 }; // for initialization. 
| >   object a; a = (object) { 0, 0 }; 
|  
| This recommendation, to use different syntax for initialization than for 
| assignment, goes against the ISO C++ grammar.

Look: Anything you've done until now *goes against* the ISO C++ grammar.
Your complain is NOT founded as far as standard C++ is concerned.  It
is NOT founded as far as GNU C++ is concerned.

I've taken  your PR as a feature request instead of a bug report and
suggested alterntaives that have *high chance* to get into the next
version of ISO C++ standard. 

The initialization syntax *is* ISO C++ syntax.  It is also ISO C syntax.

The proposed syntax in assignment is under discussion in the C++
evolution working group.  And currently it is ISO C syntax.
You have your bread.  You may even be able to eat it.

-- Gaby


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

* [Bug c++/12615] [3.3 Regression] initializer syntax for POD structs gives parse error
  2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2003-10-18 11:32 ` gdr at integrable-solutions dot net
@ 2003-10-18 15:21 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-18 15:21 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|3.3.3                       |3.4


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-18 15:20 -------
Closing as will not fix for a 3.3.x series and this is fixed for 3.4.


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

end of thread, other threads:[~2003-10-18 15:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 19:37 [Bug c++/12615] New: initializer syntax for PAD structs gives parse error gcc-bugzilla at gcc dot gnu dot org
2003-10-14 19:47 ` [Bug c++/12615] [3.3 Regression] " pinskia at gcc dot gnu dot org
2003-10-14 19:54 ` gdr at integrable-solutions dot net
2003-10-14 21:38   ` Joseph S. Myers
2003-10-14 22:10     ` Gabriel Dos Reis
2003-10-14 20:13 ` schwab at suse dot de
2003-10-14 20:40 ` gdr at integrable-solutions dot net
2003-10-14 20:46 ` bruno at clisp dot org
2003-10-14 21:38 ` [Bug c++/12615] [3.3 Regression] initializer syntax for POD " jsm at polyomino dot org dot uk
2003-10-14 21:40 ` gdr at integrable-solutions dot net
2003-10-15 10:44 ` bruno at clisp dot org
2003-10-15 11:20 ` gdr at integrable-solutions dot net
2003-10-15 11:49 ` bruno at clisp dot org
2003-10-15 16:23 ` gdr at integrable-solutions dot net
2003-10-15 18:43 ` bruno at clisp dot org
2003-10-18 11:32 ` gdr at integrable-solutions dot net
2003-10-18 15:21 ` 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).