This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1980: Error assigning const array



>Number:         1980
>Category:       c++
>Synopsis:       Error assigning const array
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 14 05:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Frank Pilhofer
>Release:        2.97 20010122 (experimental)
>Organization:
>Environment:
System: Linux rose 2.2.13 #1 Mon Nov 8 15:08:22 CET 1999 i586 unknown
Architecture: i586
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../configure --prefix=/local/pkg/gcc/20010122 --with-gnu-as=/local/bin/as --with-gnu-ld=/local/bin/ld
>Description:
The following code does not compile, gcc says
test.cc: In method `S::S(const S &)':
test.cc:5: incompatible types in assignment of `const char[2]' to `char[2]'
>How-To-Repeat:
struct S {
  char x[2];
  S( const S &s )
  {
    x = s.x;
  }
};
>Fix:
It works if constness is cast away, as in
struct S {
  char x[2];
  S( const S &s )
  {
    x = ((S&)s).x;
  }
};

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]