This is the mail archive of the gcc-prs@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]
Other format: [Raw text]

c++/7129: C++ min/max assignment operators (<?= and >?=) with structs cause segmentation fault in 3.x


>Number:         7129
>Category:       c++
>Synopsis:       C++ min/max assignment operators (<?= and >?=) with structs cause segmentation fault in 3.x
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 25 18:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1
>Organization:
Oberlin College Computer Science
>Environment:
System: Linux pippin.cs.oberlin.edu 2.4.17 #15 Fri Feb 1 14:02:22 EST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.1/configure --prefix=/usr/public --program-suffix=3
>Description:

  Using the min/max-with-assignment operators (<?= and >?=; a GNU
  extension to C++) where one or both of the arguments are of
  aggregate type (struct/class), causes an internal error
  (Segmentation fault).  It doesn't matter if the relevant relational
  operator (< or >) has been defined for the types; an attempt to
  declare <?= or >?= itself for such types causes the error to occur
  on that line instead.  If primitive types are used (pointers count
  for this) for both types, the code compiles successfully if
  comparison is defined on both types, or gives the correct error if
  it isn't (e.g. char* and double).
  
  This doesn't occur with just <? and >?; interestingly, the
  assignment forms don't seem to actually be documented in the manual,
  but do work on primitive types.

>How-To-Repeat:
  Fortunately, this requires no includes or preprocessing.  Example:
// code starts here
struct s_t { };
void foo(void) { 
  s_t s; int i;
  s<?=i;
}
// output starts here
bugtest.cc: In function `void foo()':
bugtest.cc:4: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
// end.

  Also try trivial modifications: switching the args on line 4, using
  "s" for both of them, using "i" for both of them, removing the '=',
  etc.; this is mainly how I got the details in the Description.
  
>Fix:
  This extension doesn't provide any functionality not present in the
  core language; it can be worked around by writing in terms of
  standard language primitives, the non-assignment forms of the
  extension operators, or using the min() and max() templates from the
  standard header "algorithm".
>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]