public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14531] New: pessimise code, loose constantness
@ 2004-03-11 12:47 smelkov at mph1 dot phys dot spbu dot ru
  2004-03-11 12:49 ` [Bug c++/14531] " smelkov at mph1 dot phys dot spbu dot ru
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: smelkov at mph1 dot phys dot spbu dot ru @ 2004-03-11 12:47 UTC (permalink / raw)
  To: gcc-bugs

I've found some case, where g++ fails to recognize an expression as compile time const 
(ok, it recognizes it, but delays initialization till program run) 
 
 
Here is the case source with g++ and icc8 assember output. Just look on how subidx_rmap is 
initialized. 
 
--- const_array.cpp --- 
    //! calculates offset of (unambigous, non-virtual) BASE in CHILD 
    //! @param  TYPE    class inhereted from BASE 
    //! @param  BASE    the base class for TYPE 
    //! @note it looks like C++ mandates NULL pointer to be always casted to NULL, hence i 	 
    //!           use 0x1000 here. 
#define base_delta(TYPE, BASE)  ( (signed long)((static_cast<BASE*>( 
reinterpret_cast<TYPE*>(0x1000UL) ))) - 0x1000 ) 
 
struct A 
{ 
	int a; 
}; 
 
struct B 
{ 
    int b; 
}; 
 
 
struct C : public A, public B 
{ 
}; 
 
 
 
const signed long subidx_rmap[] =  
{ 
    base_delta(C, B), 
    33, 
    137 
}; 
 
--------------------------------- 
 
---const_array.s.g++---- 
	.file	"const_array.cpp" 
	.local	subidx_rmap 
	.comm	subidx_rmap,12,4 
	.text 
	.align 2 
	.type	__static_initialization_and_destruction_0(int, int), @function 
__static_initialization_and_destruction_0(int, int): 
.LFB3: 
	pushl	%ebp 
.LCFI0: 
	movl	%esp, %ebp 
.LCFI1: 
	cmpl	$65535, 12(%ebp) 
	jne	.L1 
	cmpl	$1, 8(%ebp) 
	jne	.L1 
	movl	$4, %eax 
	movl	%eax, subidx_rmap 
	movl	$33, subidx_rmap+4 
	movl	$137, subidx_rmap+8 
.L1: 
	popl	%ebp 
	ret 
.LFE3: 
	.size	__static_initialization_and_destruction_0(int, int), 
.-__static_initialization_and_destruction_0(int, int) 
	.align 2 
	.type	_GLOBAL__I_const_array.cppG85Xva, @function 
_GLOBAL__I_const_array.cppG85Xva: 
.LFB5: 
	pushl	%ebp 
.LCFI2: 
	movl	%esp, %ebp 
.LCFI3: 
	subl	$8, %esp 
.LCFI4: 
	movl	$65535, 4(%esp) 
	movl	$1, (%esp) 
	call	__static_initialization_and_destruction_0(int, int) 
	leave 
	ret 
.LFE5: 
	.size	_GLOBAL__I_const_array.cppG85Xva, .-_GLOBAL__I_const_array.cppG85Xva 
	.section	.ctors,"aw",@progbits 
	.align 4 
	.long	_GLOBAL__I_const_array.cppG85Xva 
	.section	.note.GNU-stack,"",@progbits 
	.ident	"GCC: (GNU) 3.3.3" 
-------------------------------- 
 
---const_array.s.icc--- 
# -- Machine type IA32 
# mark_description "Intel(R) C++ Compiler for 32-bit applications, Version 8.0   Build 
20031016Z %s"; 
# mark_description "-long_double -Wall -S -o const_array.s.icc"; 
	.ident "Intel(R) C++ Compiler for 32-bit applications, Version 8.0   Build 20031016Z %s" 
	.ident "-long_double -Wall -S -o const_array.s.icc" 
	.file "const_array.cpp" 
	.text 
	.data 
	.align 4 
	.bss 
	.align 4 
	.section .rodata, "a" 
	.align 4 
	.section .data1, "wa" 
	.align 4 
	.section .text1, "wa" 
	.align 4 
	.section .rodata, "a" 
	.align 4 
subidx_rmap: 
	.long 4	# s32 
	.long 33	# s32 
	.long 137	# s32 
	.type	subidx_rmap,@object 
	.size	subidx_rmap,12 
	.data 
	.section .text 
.LNDBG_TXe: 
# End 
--------------------------------- 
 
g++ info: 
[kirr@tugrik test]$ g++ -v 
Reading specs from /usr/local/gcc-3.3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs 
Configured with: ../gcc-3.3.3/configure --prefix=/usr/local/gcc-3.3.3 --enable-threads=posix 
--enable-languages=c,c++,f77 --enable-checking --disable-nls 
Thread model: posix 
gcc version 3.3.3

-- 
           Summary: pessimise code, loose constantness
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: smelkov at mph1 dot phys dot spbu dot ru
                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=14531


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

* [Bug c++/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
@ 2004-03-11 12:49 ` smelkov at mph1 dot phys dot spbu dot ru
  2004-03-11 15:55 ` [Bug middle-end/14531] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: smelkov at mph1 dot phys dot spbu dot ru @ 2004-03-11 12:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From smelkov at mph1 dot phys dot spbu dot ru  2004-03-11 12:49 -------
Just to note: turning optimization on changes nothing. 

-- 


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


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

* [Bug middle-end/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
  2004-03-11 12:49 ` [Bug c++/14531] " smelkov at mph1 dot phys dot spbu dot ru
@ 2004-03-11 15:55 ` pinskia at gcc dot gnu dot org
  2004-04-19 22:50 ` 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-03-11 15:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-11 15:55 -------
Confirmed.
Looks like this tree is not folded:
4096u == 0 ? -0x00000000000001000l : 4l;

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |middle-end
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-11 15:55:39
               date|                            |


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


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

* [Bug middle-end/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
  2004-03-11 12:49 ` [Bug c++/14531] " smelkov at mph1 dot phys dot spbu dot ru
  2004-03-11 15:55 ` [Bug middle-end/14531] " pinskia at gcc dot gnu dot org
@ 2004-04-19 22:50 ` pinskia at gcc dot gnu dot org
  2004-04-20  4:33 ` cvs-commit 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-04-19 22:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-19 19:37 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01185.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug middle-end/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
                   ` (2 preceding siblings ...)
  2004-04-19 22:50 ` pinskia at gcc dot gnu dot org
@ 2004-04-20  4:33 ` cvs-commit at gcc dot gnu dot org
  2004-04-20  5:26 ` pinskia at gcc dot gnu dot org
  2004-04-20  9:09 ` giovannibajo at libero dot it
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-04-20  4:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-04-20 02:52 -------
Subject: Bug 14531

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2004-04-20 02:52:18

Modified files:
	gcc/cp         : ChangeLog class.c 

Log message:
	PR middle-end/14531
	* class.c (build_base_path): Call fold whilst building the NULL
	pointer check expression trees.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4034&r2=1.4035
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.606&r2=1.607



-- 


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


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

* [Bug middle-end/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
                   ` (3 preceding siblings ...)
  2004-04-20  4:33 ` cvs-commit at gcc dot gnu dot org
@ 2004-04-20  5:26 ` pinskia at gcc dot gnu dot org
  2004-04-20  9:09 ` giovannibajo at libero dot it
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-20  5:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-20 03:01 -------
Fixed on the mainline for 3.5.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.5.0


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


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

* [Bug middle-end/14531] pessimise code, loose constantness
  2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
                   ` (4 preceding siblings ...)
  2004-04-20  5:26 ` pinskia at gcc dot gnu dot org
@ 2004-04-20  9:09 ` giovannibajo at libero dot it
  5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-20  9:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-04-20 07:45 -------
Roger, you didn't commit a testcase for this bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sayle at gcc dot gnu dot
                   |                            |org, giovannibajo at libero
                   |                            |dot it


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


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

end of thread, other threads:[~2004-04-20  7:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-11 12:47 [Bug c++/14531] New: pessimise code, loose constantness smelkov at mph1 dot phys dot spbu dot ru
2004-03-11 12:49 ` [Bug c++/14531] " smelkov at mph1 dot phys dot spbu dot ru
2004-03-11 15:55 ` [Bug middle-end/14531] " pinskia at gcc dot gnu dot org
2004-04-19 22:50 ` pinskia at gcc dot gnu dot org
2004-04-20  4:33 ` cvs-commit at gcc dot gnu dot org
2004-04-20  5:26 ` pinskia at gcc dot gnu dot org
2004-04-20  9:09 ` giovannibajo at libero dot it

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