public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
@ 2003-08-23  1:50 ` dhazeghi at yahoo dot com
  2004-09-14 13:09 ` rguenth at tat dot physik dot uni-tuebingen dot de
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  1:50 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
  2003-08-23  1:50 ` [Bug c++/10479] __alignof__(double) not compile time constant inside template class dhazeghi at yahoo dot com
@ 2004-09-14 13:09 ` rguenth at tat dot physik dot uni-tuebingen dot de
  2004-09-14 14:46 ` gdr at integrable-solutions dot net
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at tat dot physik dot uni-tuebingen dot de @ 2004-09-14 13:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-09-14 13:09 -------
Same with using sizeof() instead of __alignof__.  Can we please clarify if we
are supporting this syntax?  It seems at least that sizeof() is a constant
expression
in the sense of the C++ standard.  So - are we supposed to support any
conforming constant expression as argument to attribute(aligned)?

I'd like to CC a C++ maintainer here, but it seems just for one comment I cannot
do this, so, Mark added to PR CC list.

Thanks,
Richard.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at codesourcery dot com


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
  2003-08-23  1:50 ` [Bug c++/10479] __alignof__(double) not compile time constant inside template class dhazeghi at yahoo dot com
  2004-09-14 13:09 ` rguenth at tat dot physik dot uni-tuebingen dot de
@ 2004-09-14 14:46 ` gdr at integrable-solutions dot net
  2004-09-14 14:51 ` rguenth at tat dot physik dot uni-tuebingen dot de
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-09-14 14:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-09-14 14:46 -------
Subject: Re:  __alignof__(double) not compile time constant inside template class

"rguenth at tat dot physik dot uni-tuebingen dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| Same with using sizeof() instead of __alignof__.  Can we please clarify if we

You'e right.  The issue has nothing to do with __alignof__ extension.
Using sizeof is probably better.

| are supporting this syntax?  It seems at least that sizeof() is a constant
| expression
| in the sense of the C++ standard.  So - are we supposed to support any
| conforming constant expression as argument to attribute(aligned)?
| 
| I'd like to CC a C++ maintainer here, but it seems just for one comment I cannot
| do this, so, Mark added to PR CC list.


I know (or at least I knew) what is going on here.  
I was meaning to send a detailed explanation of this to the general
list a long time ago.  We have another instance of this bug somewhere,
I tink.

The executive summary is that __attribute__ was designed to ignore
language lookup rules -- yep, lookup!

When parsing attributes, the parser interprets any identifier (or
anything that looks so) as an attribute name/value or keyword.  In
particular, it does not understand symbolic constants.  It it is
expecting to see a constant expression, then it really means a
literal or combination of such; but not computed constant expressions
or symbolic constant expressions.  That is just plain stupid but it
works for C, and that is what they were designed for.
Given the above situation, tsubst() does not even try to look into
attributes -- because there is no much it would do there since
attributes disobey language scope rules.

To solve, this problem, one would have to redesign the name lookup
rules for attributes.  Or/and provide an "escaping" mechanism for the
compiler to follow usual language rules.

-- Gaby


-- 


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (2 preceding siblings ...)
  2004-09-14 14:46 ` gdr at integrable-solutions dot net
@ 2004-09-14 14:51 ` rguenth at tat dot physik dot uni-tuebingen dot de
  2004-09-14 15:05 ` gdr at integrable-solutions dot net
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at tat dot physik dot uni-tuebingen dot de @ 2004-09-14 14:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-09-14 14:51 -------
Subject: Re:  __alignof__(double) not compile time constant
 inside template class

> To solve, this problem, one would have to redesign the name lookup
> rules for attributes.  Or/and provide an "escaping" mechanism for the
> compiler to follow usual language rules.

Does this "match" with that it works for non-template classes? I.e.

struct foo2 {
        float bar __attribute__((aligned(__alignof__(double))));
};

just works.  Remember that "double" is not a dependent type - I would
certainly understand that using a dependent type would not work (or
would be harder to do).  But not allowing non-dependent types in template
classes doesn't look difficult (from a users point of view), are they?

Thanks for trying to explain,

Richard.



-- 


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (3 preceding siblings ...)
  2004-09-14 14:51 ` rguenth at tat dot physik dot uni-tuebingen dot de
@ 2004-09-14 15:05 ` gdr at integrable-solutions dot net
  2004-09-14 15:11 ` rguenth at tat dot physik dot uni-tuebingen dot de
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-09-14 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-09-14 15:05 -------
Subject: Re:  __alignof__(double) not compile time constant inside template class

"rguenth at tat dot physik dot uni-tuebingen dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| ------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-09-14 14:51 -------
| Subject: Re:  __alignof__(double) not compile time constant
|  inside template class
| 
| > To solve, this problem, one would have to redesign the name lookup
| > rules for attributes.  Or/and provide an "escaping" mechanism for the
| > compiler to follow usual language rules.
| 
| Does this "match" with that it works for non-template classes? I.e.
| 
| struct foo2 {
|         float bar __attribute__((aligned(__alignof__(double))));
| };
| 
| just works.  Remember that "double" is not a dependent type - I would

I know "double" is not dependent type.  Did you doubt that?

As I said, attributes are implemented in a way that defy language rules.  
Inside, templates, it is even worse. And tsubst() does not even look there.  

Try

     const int N = 4;

     struct S {
        enum { M = 4 };
        float ahar __attribute__((aligned(N)));
        float bhar __attribute__((aligned(M)));
     };


| certainly understand that using a dependent type would not work (or
| would be harder to do).  But not allowing non-dependent types in template
| classes doesn't look difficult (from a users point of view), are they?

Do you believe I'm against making this work?  I find it very annoying,
and happen to qualify as plain stupid.  I was just explaining what was
going on.  

Some time ago, I tried to fix that but it blew up.  It may probably be
not difficult, but it you don't try you probably won't figure it out.

-- Gaby


-- 


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (4 preceding siblings ...)
  2004-09-14 15:05 ` gdr at integrable-solutions dot net
@ 2004-09-14 15:11 ` rguenth at tat dot physik dot uni-tuebingen dot de
  2004-10-15 12:05 ` giovannibajo at libero dot it
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at tat dot physik dot uni-tuebingen dot de @ 2004-09-14 15:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-09-14 15:11 -------
Subject: Re:  __alignof__(double) not compile time constant
 inside template class

On 14 Sep 2004, gdr at integrable-solutions dot net wrote:

> I know "double" is not dependent type.  Did you doubt that?

No, I thought you maybe missed it.  I thought so because I cannot
see the difference between the templated and non-templated variant
- of course just because of my ignorance.

> Do you believe I'm against making this work?  I find it very annoying,
> and happen to qualify as plain stupid.  I was just explaining what was
> going on.

Ok thanks, I'll guess target-milestone would be 4.1 earliest then.

> Some time ago, I tried to fix that but it blew up.  It may probably be
> not difficult, but it you don't try you probably won't figure it out.

Of course.

Richard.



-- 


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (5 preceding siblings ...)
  2004-09-14 15:11 ` rguenth at tat dot physik dot uni-tuebingen dot de
@ 2004-10-15 12:05 ` giovannibajo at libero dot it
  2004-10-16  2:01 ` giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-15 12:05 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |giovannibajo at gcc dot gnu
                   |dot org                     |dot org
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (6 preceding siblings ...)
  2004-10-15 12:05 ` giovannibajo at libero dot it
@ 2004-10-16  2:01 ` giovannibajo at libero dot it
  2004-10-16  3:38 ` mark at codesourcery dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-16  2:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-16 02:01 -------
Patch submitted:
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01319.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|giovannibajo at gcc dot gnu |giovannibajo at libero dot
                   |dot org                     |it
           Keywords|                            |patch


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (7 preceding siblings ...)
  2004-10-16  2:01 ` giovannibajo at libero dot it
@ 2004-10-16  3:38 ` mark at codesourcery dot com
  2004-10-16 11:05 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: mark at codesourcery dot com @ 2004-10-16  3:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2004-10-16 03:38 -------
Subject: Re:  __alignof__(double) not compile time constant
 inside template class

giovannibajo at libero dot it wrote:

>------- Additional Comments From giovannibajo at libero dot it  2004-10-16 02:01 -------
>Patch submitted:
>http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01319.html
>  
>
OK.



-- 


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


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

* [Bug c++/10479] __alignof__(double) not compile time constant inside template class
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (8 preceding siblings ...)
  2004-10-16  3:38 ` mark at codesourcery dot com
@ 2004-10-16 11:05 ` cvs-commit at gcc dot gnu dot org
  2004-10-16 11:06 ` [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-16 11:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-16 11:05 -------
Subject: Bug 10479

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2004-10-16 11:04:59

Modified files:
	gcc/cp         : ChangeLog parser.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: attrib16.C 

Log message:
	PR c++/10479
	* parser.c (cp_parser_parenthesized_expression_list): Fold
	non-dependent expressions in attribute lists.
	
	PR c++/10479
	* g++.dg/ext/attrib16.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4439&r2=1.4440
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.264&r2=1.265
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4461&r2=1.4462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib16.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (9 preceding siblings ...)
  2004-10-16 11:05 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-16 11:06 ` giovannibajo at libero dot it
  2004-10-16 15:43 ` rguenth at tat dot physik dot uni-tuebingen dot de
  2004-10-16 18:16 ` giovannibajo at libero dot it
  12 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-16 11:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-16 11:06 -------
Fixed in GCC 4.0.0. Thanks for your report!

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
            Summary|__alignof__(double) not     |alignof and sizeof (and
                   |compile time constant inside|other expressions) in
                   |template class              |attributes does not compile
                   |                            |inside template classes
   Target Milestone|---                         |4.0.0


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


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

* [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (10 preceding siblings ...)
  2004-10-16 11:06 ` [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes giovannibajo at libero dot it
@ 2004-10-16 15:43 ` rguenth at tat dot physik dot uni-tuebingen dot de
  2004-10-16 18:16 ` giovannibajo at libero dot it
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at tat dot physik dot uni-tuebingen dot de @ 2004-10-16 15:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-10-16 15:42 -------
Subject: Re:  alignof and sizeof (and other expressions) in
 attributes does not compile inside template classes

giovannibajo at libero dot it wrote:
> ------- Additional Comments From giovannibajo at libero dot it  2004-10-16 11:06 -------
> Fixed in GCC 4.0.0. Thanks for your report!

Can this be trivially backported to 3.4?  That would be cool.

Thanks,
Richard.



-- 


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


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

* [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes
       [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
                   ` (11 preceding siblings ...)
  2004-10-16 15:43 ` rguenth at tat dot physik dot uni-tuebingen dot de
@ 2004-10-16 18:16 ` giovannibajo at libero dot it
  12 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-16 18:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-16 18:16 -------
There are good chances that this can be easily backported to 3.4. On the other 
hand, this is not a regression, so you will need to talk Mark into doing it. I 
can easily test and commit the patch also there, if Mark agrees.

-- 


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


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

end of thread, other threads:[~2004-10-16 18:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030424121601.10479.rguenth@tat.physik.uni-tuebingen.de>
2003-08-23  1:50 ` [Bug c++/10479] __alignof__(double) not compile time constant inside template class dhazeghi at yahoo dot com
2004-09-14 13:09 ` rguenth at tat dot physik dot uni-tuebingen dot de
2004-09-14 14:46 ` gdr at integrable-solutions dot net
2004-09-14 14:51 ` rguenth at tat dot physik dot uni-tuebingen dot de
2004-09-14 15:05 ` gdr at integrable-solutions dot net
2004-09-14 15:11 ` rguenth at tat dot physik dot uni-tuebingen dot de
2004-10-15 12:05 ` giovannibajo at libero dot it
2004-10-16  2:01 ` giovannibajo at libero dot it
2004-10-16  3:38 ` mark at codesourcery dot com
2004-10-16 11:05 ` cvs-commit at gcc dot gnu dot org
2004-10-16 11:06 ` [Bug c++/10479] alignof and sizeof (and other expressions) in attributes does not compile inside template classes giovannibajo at libero dot it
2004-10-16 15:43 ` rguenth at tat dot physik dot uni-tuebingen dot de
2004-10-16 18:16 ` 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).