public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14083] New: ICE in conditional expression operator with throw
@ 2004-02-09 13:40 gcc at online dot nl
  2004-02-09 14:03 ` [Bug c++/14083] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gcc at online dot nl @ 2004-02-09 13:40 UTC (permalink / raw)
  To: gcc-bugs

The following code generates an ICE:

int main(int argc,char**argv)
{
  std::string s("hello world");
  try {
    cerr << ( s=="hello" ? s : throw exception() ) << endl;
  } catch (...) {
    cerr << "Exception" << endl;
  };
};

The program should output 'Exception'.

ISO 14882-98:

(15)
A throw-expression is of type void. 

(5.16)
If either the second or the third operand has type void, then the
lvalue-to-rvalue ... standard conversions are performed on the second and third
operands, and one of the following shall hold:

- The second or third operand (but not both) is a throw-expression (15.1); the
result is of the type of the other and is an rvalue.

...

END ISO14882-98

Personal Interpretation:

Conditional operator in the above code: 

 s=="hello" ? s : throw exception()

1st operand/expression: 's=="hello"' (type bool)
2nd operand/expression: 's' (type std::string)
3rd operand/expression: 'throw exception()' (type void)

The third operand (throw-expression) is of type void and with that, one of the
conditions in 5.16 holds, so the result should be of the type of the other
(second) expression (std::string), but the compiler generates an ICE as follows:

[user@host] /usr/local/bin/g++ test.cc      
test.cc: In function `int main(int, char**)':
test.cc:764: internal compiler error: in cp_expr_size, at cp/cp-lang.c:312
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

ICE does not occur if in above code type of 's' is substituted for integral type
(together with appropriate integral comparisons in above code).

Experienced with default redhat 9 i386 compiler and now with self compiled gcc
3.3.2 i686-pc-linux-gnu compiler.

-- 
           Summary: ICE in conditional expression operator with throw
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at online dot nl
                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


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
@ 2004-02-09 14:03 ` bangerth at dealii dot org
  2004-02-09 14:22 ` bangerth at dealii dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-02-09 14:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-09 14:03 -------
Confirmed, and this hasn't been fixed as that other bug with 
throw-expressions in conditionals. This still fails with 
3.3.3, 3.4 and mainline. It works with 3.2.3, though, so this 
is a regression. 
 
Here's a legal testcase, though I don't have the time to reduce 
it: 
--------------------- 
#include <iostream> 
#include <string> 
using namespace std; 
int main(int argc,char**argv) 
{ 
  std::string s("hello world"); 
  try { 
    cerr << ( s=="hello" ? s : throw exception() ) << endl; 
  } catch (...) { 
    cerr << "Exception" << endl; 
  }; 
}; 
------------------- 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.3.1 3.3.3 3.4.0 3.5.0
      Known to work|                            |3.2.3
            Summary|ICE in conditional          |[3.3/3.4/3.5 regression] ICE
                   |expression operator with    |in conditional expression
                   |throw                       |operator with throw
   Target Milestone|---                         |3.3.3


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
  2004-02-09 14:03 ` [Bug c++/14083] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
@ 2004-02-09 14:22 ` bangerth at dealii dot org
  2004-02-09 14:36 ` bangerth at dealii dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-02-09 14:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-09 14:22 -------
This only needs one header file: 
----------------- 
#include <string> 
 
int main() 
{ 
  std::string s; 
  try { 
    s=="" ? s : throw 1; 
  } catch (...) {}; 
} 
----------- 

-- 


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
  2004-02-09 14:03 ` [Bug c++/14083] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
  2004-02-09 14:22 ` bangerth at dealii dot org
@ 2004-02-09 14:36 ` bangerth at dealii dot org
  2004-02-13 19:45 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-02-09 14:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-09 14:36 -------
OK, here's the redux: 
----------------------- 
struct A { 
    A() throw() { } 
    A(const A&) throw() { } 
}; 
 
struct X { 
    A a; 
    X(); 
    X& operator=(const X& __str); 
}; 
 
bool operator==(const X& __lhs, const char* __rhs); 
        
int main() { 
  X x; 
  x=="" ? x : throw 1; 
} 
------------------- 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-09 14:36:09
               date|                            |


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (2 preceding siblings ...)
  2004-02-09 14:36 ` bangerth at dealii dot org
@ 2004-02-13 19:45 ` mmitchel at gcc dot gnu dot org
  2004-02-13 20:11 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-02-13 19:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-13 19:45 -------
Working on a fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (3 preceding siblings ...)
  2004-02-13 19:45 ` mmitchel at gcc dot gnu dot org
@ 2004-02-13 20:11 ` cvs-commit at gcc dot gnu dot org
  2004-02-13 20:12 ` cvs-commit at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-13 20:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-13 20:11 -------
Subject: Bug 14083

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-02-13 20:11:35

Modified files:
	gcc/cp         : ChangeLog call.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/eh: cond2.C 

Log message:
	PR c++/14083
	* call.c (build_conditional_expr): Call force_rvalue on the
	non-void operand in the case that one result is a throw-expression
	and the other is not.
	
	PR c++/14083
	* g++.dg/eh/cond2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3952&r2=1.3953
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.461&r2=1.462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3495&r2=1.3496
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/eh/cond2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/14083] [3.3/3.4/3.5 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (4 preceding siblings ...)
  2004-02-13 20:11 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-13 20:12 ` cvs-commit at gcc dot gnu dot org
  2004-02-13 20:14 ` [Bug c++/14083] [3.3 " mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-13 20:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-13 20:12 -------
Subject: Bug 14083

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-02-13 20:12:29

Modified files:
	gcc/cp         : ChangeLog call.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/eh: cond2.C 

Log message:
	PR c++/14083
	* call.c (build_conditional_expr): Call force_rvalue on the
	non-void operand in the case that one result is a throw-expression
	and the other is not.
	
	PR c++/14083
	* g++.dg/eh/cond2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.48&r2=1.3892.2.49
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.6&r2=1.452.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.72&r2=1.3389.2.73
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/eh/cond2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug c++/14083] [3.3 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (5 preceding siblings ...)
  2004-02-13 20:12 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-13 20:14 ` mmitchel at gcc dot gnu dot org
  2004-02-15 12:47 ` gdr at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-02-13 20:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-13 20:14 -------
Fixed in GCC 3.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|mark at codesourcery dot com|unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW
      Known to fail|3.3.1 3.3.3 3.4.0 3.5.0     |3.3.1 3.3.3
            Summary|[3.3/3.4/3.5 regression] ICE|[3.3 regression] ICE in
                   |in conditional expression   |conditional expression
                   |operator with throw         |operator with throw


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


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

* [Bug c++/14083] [3.3 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (6 preceding siblings ...)
  2004-02-13 20:14 ` [Bug c++/14083] [3.3 " mmitchel at gcc dot gnu dot org
@ 2004-02-15 12:47 ` gdr at gcc dot gnu dot org
  2004-02-22 17:02 ` cvs-commit at gcc dot gnu dot org
  2004-02-22 17:02 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-02-15 12:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-02-15 12:47 -------
Adjust milestone

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.3.3                       |3.3.4


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


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

* [Bug c++/14083] [3.3 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (7 preceding siblings ...)
  2004-02-15 12:47 ` gdr at gcc dot gnu dot org
@ 2004-02-22 17:02 ` cvs-commit at gcc dot gnu dot org
  2004-02-22 17:02 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-22 17:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-22 17:02 -------
Subject: Bug 14083

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	gdr@gcc.gnu.org	2004-02-22 17:02:13

Modified files:
	gcc/cp         : ChangeLog call.c 
Added files:
	gcc/testsuite/g++.dg/eh: cond2.C 

Log message:
	Backport from mainline
	2004-02-13  Mark Mitchell  <mark@codesourcery.com>
	PR c++/14083
	* call.c (build_conditional_expr): Call force_rvalue on the
	non-void operand in the case that one result is a throw-expression
	and the other is not.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.251&r2=1.3076.2.252
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.39&r2=1.341.2.40
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/eh/cond2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1



-- 


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


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

* [Bug c++/14083] [3.3 regression] ICE in conditional expression operator with throw
  2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
                   ` (8 preceding siblings ...)
  2004-02-22 17:02 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-22 17:02 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-02-22 17:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-02-22 17:02 -------
Patch backported to gcc-3_3-branch.

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


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


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

end of thread, other threads:[~2004-02-22 17:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-09 13:40 [Bug c++/14083] New: ICE in conditional expression operator with throw gcc at online dot nl
2004-02-09 14:03 ` [Bug c++/14083] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
2004-02-09 14:22 ` bangerth at dealii dot org
2004-02-09 14:36 ` bangerth at dealii dot org
2004-02-13 19:45 ` mmitchel at gcc dot gnu dot org
2004-02-13 20:11 ` cvs-commit at gcc dot gnu dot org
2004-02-13 20:12 ` cvs-commit at gcc dot gnu dot org
2004-02-13 20:14 ` [Bug c++/14083] [3.3 " mmitchel at gcc dot gnu dot org
2004-02-15 12:47 ` gdr at gcc dot gnu dot org
2004-02-22 17:02 ` cvs-commit at gcc dot gnu dot org
2004-02-22 17:02 ` gdr 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).