public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool
@ 2004-10-26 13:30 bangerth at dealii dot org
  2004-10-26 13:31 ` [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-10-26 13:30 UTC (permalink / raw)
  To: gcc-bugs

For this code 
----------------- 
template <typename = typeof(1==1)> struct X { X(){} }; 
template struct X<>; 
----------------- 
I would expect an instantiation of X<bool>, and indeed got it up to 
3.4. However, since 4.0 we get X<int>: 
 
g/x> /home/bangerth/bin/gcc-3.4*/bin/c++ -c x.cc ; nm -C x.o 
00000000 W X<bool>::X() 
00000000 W X<bool>::X() 
g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c x.cc ; nm -C x.o 
00000000 W X<int>::X() 
00000000 W X<int>::X() 
 
 
This is somehow odd, since for a related piece of code 
------------------- 
template <typename> struct X {}; 
void foo(X<typeof(1==1)>) {} 
------------------- 
there is no regression: 
 
g/x> /home/bangerth/bin/gcc-3.4*/bin/c++ -c y.cc ; nm -C y.o 
00000000 T foo(X<bool>) 
g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c y.cc ; nm -C y.o 
00000000 T foo(X<bool>) 
 
W.

-- 
           Summary: [4.0 regression] typeof(1==1) is now int instead of bool
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
@ 2004-10-26 13:31 ` bangerth at dealii dot org
  2004-10-26 13:34 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-10-26 13:31 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.0
      Known to work|                            |2.95 3.2 3.3 3.4.3
            Summary|[4.0 regression]            |[4.0 regression]
                   |typeof(1==1) is now int     |typeof(1==1) is now int
                   |instead of bool             |instead of bool in template
                   |                            |default arguments
   Target Milestone|---                         |4.0.0


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


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
  2004-10-26 13:31 ` [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments bangerth at dealii dot org
@ 2004-10-26 13:34 ` pinskia at gcc dot gnu dot org
  2004-10-26 13:36 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-26 13:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-26 13:34 -------
Here is a testcase which we can see the problem with rejecting the code (which is very useful for the 
regression hunter :) ):
template <class T> struct Y;
template <>struct Y<bool>{};

template <typename T = typeof(1==1)> struct X { Y<T> a; }; 
template struct X<>; 

: Search converges between 2004-09-27-161002-trunk (#564) and 2004-09-28-014001-trunk 
(#565).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-26 13:34:27
               date|                            |


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


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
  2004-10-26 13:31 ` [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments bangerth at dealii dot org
  2004-10-26 13:34 ` pinskia at gcc dot gnu dot org
@ 2004-10-26 13:36 ` pinskia at gcc dot gnu dot org
  2004-10-26 21:58 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-26 13:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-26 13:36 -------
Almost certain that this was caused by:
2004-09-27  Mark Mitchell  <mark@codesourcery.com>
        
        PR c++/17642
        * cp-tree.h (fold_if_not_in_template): New function.
        * call.c (build_conditional_expr): Use fold_if_not_in_template.
        (build_cxx_call): Likewise.
        * cvt.c (convert_to_complex): Likewise.
        (ocp_convert): Likewise.
        (convert): Likewise.
        (convert_force): Likewise.
        * decl.c (compute_array_index_type): Clear
        processing_template_decl while folding array bounds.
        * pt.c (convert_nontype_argument): Clear
        processing_template_decl while processing non-type argument
        initialization.
        * tree.c (fold_if_not_in_template): New function.
        * typeck.c (build_class_member_access_expr): Use
        fold_if_not_in_template.
        (build_array_ref): Likewise.
        (build_binary_op): Likewise.  Do not try to optimize computations
        when processing templates.
        (cp_pointer_int_sum): Use fold_if_not_in_template.
        (pointer_diff): Likewise.
        (build_unary_op): Likewise.
        (build_reinterpret_cast): Likewise.
        (get_delta_difference): Likewise.
        (expand_ptrmemfunc_cst): Likewise.
        (dubious_conversion_warnings): Likewise.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at codesourcery dot com
           Keywords|                            |rejects-valid


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


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
                   ` (2 preceding siblings ...)
  2004-10-26 13:36 ` pinskia at gcc dot gnu dot org
@ 2004-10-26 21:58 ` mmitchel at gcc dot gnu dot org
  2004-10-27  2:23 ` cvs-commit at gcc dot gnu dot org
  2004-10-27  4:23 ` mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-26 21:58 UTC (permalink / raw)
  To: gcc-bugs



-- 
           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=18161


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
                   ` (3 preceding siblings ...)
  2004-10-26 21:58 ` mmitchel at gcc dot gnu dot org
@ 2004-10-27  2:23 ` cvs-commit at gcc dot gnu dot org
  2004-10-27  4:23 ` mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-27  2:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-27 02:23 -------
Subject: Bug 18161

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-10-27 02:23:16

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog decl.c name-lookup.c parser.c pt.c 
	                 search.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/lookup: ns2.C 
	gcc/testsuite/g++.dg/template: enum4.C expr1.C 

Log message:
	PR c++/18093
	* search.c (current_scope): Return the innermost non-block scope,
	not the innermost non-block, non-namespace scope.
	(at_namespace_scope_p): Adjust accordingly.
	(dfs_accessible_post): Do not pass namespaces to is_friend.
	(dfs_walk_once_accessible_r): Likewise.
	* decl.c (grokvardecl): Adjust call to current_scope.
	(build_enumerator): Likewise.
	* parser.c (cp_parser_using_declaration): Likewise.
	(cp_parser_direct_declarator): Use at_namespace_scope_p instead of
	current_scope.
	(cp_parser_class_head): Adjust call to current_scope.
	* name-lookup.c (do_namespace_alias): Set the DECL_CONTEXT for the
	alias.
	
	PR c++/18020
	* pt.c (tusbst_copy_and_build): Resolve enumeration constants to
	their underlying values.
	
	PR c++/18161
	* typeck.c (build_binary_op): Honor build_type, even when in a
	template.
	
	PR c++/18093
	* g++.dg/lookup/ns2.C: New test.
	
	PR c++/18020
	* g++.dg/template/enum4.C: New test.
	
	PR c++/18161
	* g++.dg/template/expr1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4501&r2=1.4502
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4454&r2=1.4455
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1318&r2=1.1319
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.87&r2=1.88
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.270&r2=1.271
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.937&r2=1.938
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.335&r2=1.336
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.588&r2=1.589
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/ns2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/expr1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments
  2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
                   ` (4 preceding siblings ...)
  2004-10-27  2:23 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-27  4:23 ` mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-27  4:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-10-27 04:23 -------
Fixed in GCC 4.0.

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


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


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-26 13:30 [Bug c++/18161] New: [4.0 regression] typeof(1==1) is now int instead of bool bangerth at dealii dot org
2004-10-26 13:31 ` [Bug c++/18161] [4.0 regression] typeof(1==1) is now int instead of bool in template default arguments bangerth at dealii dot org
2004-10-26 13:34 ` pinskia at gcc dot gnu dot org
2004-10-26 13:36 ` pinskia at gcc dot gnu dot org
2004-10-26 21:58 ` mmitchel at gcc dot gnu dot org
2004-10-27  2:23 ` cvs-commit at gcc dot gnu dot org
2004-10-27  4:23 ` mmitchel 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).