public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling GCC With a C++ Compiler (g++)
@ 2004-10-11  9:53 Ranjit Mathew
  2004-10-12 10:06 ` Ranjit Mathew
  0 siblings, 1 reply; 63+ messages in thread
From: Ranjit Mathew @ 2004-10-11  9:53 UTC (permalink / raw)
  To: gcc

Hi,

  If I try compiling bits that include "gcc/tree.h" with
g++, I get:

/home/ranmath/src/gcc/gcc/gcc/tree.h:2504: error: member 'tree_string tree_node::string' with copy assignment operator not allowed in union

The definition of tree_string is:

  struct tree_string GTY(())
  {
    struct tree_common common;
    int length;
    const char str[1];
  };

If the "const" is removed from above, the compilation
proceeds.

There were a flurry of patches to make GCC compilable
with a C++ compiler in the recent past and I thought
it was now done... Didn't anyone else run into this?
(Apart from Tom, who suggested the fix above.)

Is this a bug? If yes, is it in the C++ compiler or
in the definition of tree_string?

Thanks,
Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/

^ permalink raw reply	[flat|nested] 63+ messages in thread
* RE: Compiling GCC With a C++ Compiler (g++)
@ 2004-10-13  3:47 Steven L. Zook
  2004-10-13  7:26 ` Gabriel Dos Reis
  0 siblings, 1 reply; 63+ messages in thread
From: Steven L. Zook @ 2004-10-13  3:47 UTC (permalink / raw)
  To: Zack Weinberg, Gabriel Dos Reis; +Cc: Geoffrey Keating, Ranjit Mathew, GCC

Pardon me for intruding here. This may not be applicable to your specifics.

C++ does have a construct for write-once storage; construction. For example,

struct sDerf { sDerf( int WriteOnceValue ) : ReadOnlyValue( WriteOnceValue ) {}
               int const ReadOnlyValue;
             };

As far as I know, this is the only "supported" method. The rest are tricks that tunnel around the language by using unions, casting, or pointer aliasing.

As far a language deficiency is concerned, I have always thought that some more modifiers than const and volatile would be useful. Especially for embedded programmers like me. The spelling of the following is not important: only the effect matters.

readonly: class members and friends can write but outsiders can only read. This would eliminate having to write accessor functions.

construct: constructor can modify any number of times in initializer list or in body but all others can only read.

interrupt: acts like volatile in non-interrupt service routines and non-volatile in an ISR (where an ISR is marked by some attribute or perhaps by name).

-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org]On Behalf Of
Zack Weinberg
Sent: Tuesday, October 12, 2004 3:58 PM
To: Gabriel Dos Reis
Cc: Geoffrey Keating; Ranjit Mathew; GCC
Subject: Re: Compiling GCC With a C++ Compiler (g++)


Gabriel Dos Reis <gdr@cs.tamu.edu> writes:

> Geoffrey Keating <geoffk@apple.com> writes:
> | The 'const' is there to indicate that the string should not be changed
> | once the STRING_CST is created;
>
> And how do you create it?

By casting away the const, as is done in build_string.  Or by
constructing the data in memory before giving it the type with the
const qualifier.

How else do you propose to enforce write-once semantics on a data
structure that is, in fact, write-once?  I am definitely with Geoff
here - this should be allowed (or, to rephrase, if C++ has no
construct which allows what we want to do here, that is a language
deficiency).

zw

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

end of thread, other threads:[~2004-10-15  7:23 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-11  9:53 Compiling GCC With a C++ Compiler (g++) Ranjit Mathew
2004-10-12 10:06 ` Ranjit Mathew
2004-10-12 13:17   ` Gabriel Dos Reis
2004-10-12 21:15   ` Geoffrey Keating
2004-10-12 23:00     ` Gabriel Dos Reis
2004-10-12 23:23       ` Zack Weinberg
2004-10-13  2:53         ` Phil Edwards
2004-10-13  6:24           ` Gabriel Dos Reis
2004-10-13 10:57             ` Andreas Schwab
2004-10-13 13:16               ` Gabriel Dos Reis
2004-10-13 13:56                 ` Andreas Schwab
2004-10-13 14:22                   ` Gabriel Dos Reis
2004-10-13 15:06                     ` Andreas Schwab
2004-10-13 15:22                       ` Gabriel Dos Reis
2004-10-13 15:33                         ` Andreas Schwab
2004-10-13 18:20                           ` Gabriel Dos Reis
2004-10-13 19:09                             ` Andreas Schwab
2004-10-13 11:47             ` Dave Korn
2004-10-13 12:24               ` Andreas Schwab
2004-10-13 13:29                 ` Gabriel Dos Reis
2004-10-13 14:10                   ` Andreas Schwab
2004-10-13 14:30                     ` Dave Korn
2004-10-13 14:50                       ` Dave Korn
2004-10-13 18:25                         ` Andreas Schwab
2004-10-13 15:04                       ` Joseph S. Myers
2004-10-13 17:01                         ` Dave Korn
2004-10-13 21:16                           ` Geoffrey Keating
2004-10-14 13:26                             ` Dave Korn
2004-10-14 13:32                               ` Gabriel Dos Reis
2004-10-14 18:40                                 ` Andreas Schwab
2004-10-14 18:48                                   ` Gabriel Dos Reis
2004-10-14 20:33                                 ` Geoffrey Keating
2004-10-14 20:19                               ` Geoffrey Keating
2004-10-15 12:03                               ` Kai Henningsen
2004-10-13 14:53                     ` Gabriel Dos Reis
2004-10-13 15:46                     ` Gabriel Dos Reis
2004-10-13 19:41                 ` Matt Austern
2004-10-13 20:29                   ` Andreas Schwab
2004-10-13 20:41                     ` Matt Austern
2004-10-13 20:58             ` Phil Edwards
2004-10-13  9:23           ` Ranjit Mathew
2004-10-13 13:09             ` Ranjit Mathew
2004-10-13 19:13               ` Richard Henderson
2004-10-13 21:55                 ` Gabriel Dos Reis
2004-10-13 13:29             ` Gabriel Dos Reis
2004-10-13  5:49         ` Gabriel Dos Reis
2004-10-13  9:19           ` Zack Weinberg
2004-10-13 13:45             ` Gabriel Dos Reis
2004-10-13 20:39           ` Geoffrey Keating
2004-10-13 21:45             ` Gabriel Dos Reis
2004-10-13 22:15               ` Geoffrey Keating
2004-10-13 22:24                 ` Gabriel Dos Reis
2004-10-13 22:53                   ` Joseph S. Myers
2004-10-13 23:19                   ` Geoffrey Keating
2004-10-14  0:21                     ` Gabriel Dos Reis
2004-10-14  6:04                       ` Andreas Schwab
2004-10-14  7:10                         ` Gabriel Dos Reis
2004-10-14 11:29                           ` Andreas Schwab
2004-10-14 13:06                             ` Gabriel Dos Reis
2004-10-14 18:37                               ` Andreas Schwab
2004-10-15 12:48                                 ` Kai Henningsen
2004-10-13  3:47 Steven L. Zook
2004-10-13  7:26 ` Gabriel Dos Reis

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).