public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36625]  New: missing diagnostic on invalid __attribute__((aligned(N)))
@ 2008-06-24 23:43 sebor at roguewave dot com
  2008-06-24 23:48 ` [Bug c++/36625] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sebor at roguewave dot com @ 2008-06-24 23:43 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

I expected to see a diagnostic for the following program regardless of whether
the template is instantiated or not, or whether the nested type is used or not.
Gcc only diagnoses the attribute when the type is used.

That said, rather than diagnosing it, it'd be even more useful to allow non
type template parameters and other constant integral expressions as arguments
to the attribute.

$ cat t.cpp && g++ t.cpp && echo PASS && g++ -DUSE_IT t.cpp
template <int N>
struct A {
    struct S { short f[3]; } __attribute__ ((aligned (N)));
};

int main ()
{
    A<123> a;
#ifdef USE_IT
    A<123>::S s;
#endif
}
PASS
t.cpp: In instantiation of ‘A<123>::S’:
t.cpp:10:   instantiated from here
t.cpp:3: error: ‘N’ was not declared in this scope
t.cpp:3: error: requested alignment is not a constant


-- 
           Summary: missing diagnostic on invalid
                    __attribute__((aligned(N)))
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


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


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

* [Bug c++/36625] missing diagnostic on invalid __attribute__((aligned(N)))
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
@ 2008-06-24 23:48 ` pinskia at gcc dot gnu dot org
  2008-06-24 23:49 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-06-24 23:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-06-24 23:47 -------
I think this is valid thing to do with aligned attribute.  On the trunk we just
get:
t.cc: In instantiation of 'A<123>::S':
t.cc:10:   instantiated from here
t.cc:3: error: requested alignment is not a constant

I think we forgot to change the template argument here.


-- 


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


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

* [Bug c++/36625] missing diagnostic on invalid __attribute__((aligned(N)))
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
  2008-06-24 23:48 ` [Bug c++/36625] " pinskia at gcc dot gnu dot org
@ 2008-06-24 23:49 ` pinskia at gcc dot gnu dot org
  2008-06-26 20:47 ` [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code sebor at roguewave dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-06-24 23:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-06-24 23:49 -------
Related to PR 19163.


-- 


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
  2008-06-24 23:48 ` [Bug c++/36625] " pinskia at gcc dot gnu dot org
  2008-06-24 23:49 ` pinskia at gcc dot gnu dot org
@ 2008-06-26 20:47 ` sebor at roguewave dot com
  2008-12-27  7:06 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sebor at roguewave dot com @ 2008-06-26 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sebor at roguewave dot com  2008-06-26 20:46 -------
Oddly enough, doubling up on the parens around N works:

template <int N>
struct A { struct S { short f[3]; } __attribute__ ((aligned ((N)))); };

int main ()
{
    A<123>::S s;
}


-- 

sebor at roguewave dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|missing diagnostic on       |bogus error on
                   |invalid                     |__attribute__((aligned(N)))
                   |__attribute__((aligned(N))) |in template code


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2008-06-26 20:47 ` [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code sebor at roguewave dot com
@ 2008-12-27  7:06 ` pinskia at gcc dot gnu dot org
  2009-12-26 18:31 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-27  7:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-12-27 07:04 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-12-27 07:04:06
               date|                            |


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (3 preceding siblings ...)
  2008-12-27  7:06 ` pinskia at gcc dot gnu dot org
@ 2009-12-26 18:31 ` paolo dot carlini at oracle dot com
  2009-12-26 19:13 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-26 18:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo dot carlini at oracle dot com  2009-12-26 18:31 -------
Let's CC Jason about this (frankly, I have *always* used double parentheses, I
thought that was the only legal syntax ;)


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (4 preceding siblings ...)
  2009-12-26 18:31 ` paolo dot carlini at oracle dot com
@ 2009-12-26 19:13 ` paolo dot carlini at oracle dot com
  2010-01-19 23:30 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-26 19:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2009-12-26 19:13 -------
Maybe related to c++/40821 ?


-- 


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (5 preceding siblings ...)
  2009-12-26 19:13 ` paolo dot carlini at oracle dot com
@ 2010-01-19 23:30 ` jason at gcc dot gnu dot org
  2010-01-20  5:51 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-19 23:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2010-01-19 23:30 -------
The problem here is that the attribute parsing code sees that the argument is
an identifier and treats it as a plain name rather than an expression; this is
to support attributes like mode which take an identifier as an argument.  I
guess we should handle this case specially.


-- 


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (6 preceding siblings ...)
  2010-01-19 23:30 ` jason at gcc dot gnu dot org
@ 2010-01-20  5:51 ` jason at gcc dot gnu dot org
  2010-04-14 20:18 ` jason at gcc dot gnu dot org
  2010-05-04 19:10 ` jason at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-20  5:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2010-01-20 05:51 -------
Created an attachment (id=19665)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19665&action=view)
patch


-- 

jason at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (7 preceding siblings ...)
  2010-01-20  5:51 ` jason at gcc dot gnu dot org
@ 2010-04-14 20:18 ` jason at gcc dot gnu dot org
  2010-05-04 19:10 ` jason at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-04-14 20:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2010-04-14 20:18 -------
Subject: Bug 36625

Author: jason
Date: Wed Apr 14 20:17:34 2010
New Revision: 158355

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158355
Log:
        PR c++/36625
        * c-common.c (attribute_takes_identifier_p): New fn.
        * c-common.h: Declare it.
cp/
        * parser.c (cp_parser_parenthesized_expression_list): Change
        is_attribute_list parm to int to indicate whether or not to
        handle initial identifier specially.
        (cp_parser_attribute_list): Use attribute_takes_identifier_p.

Added:
    trunk/gcc/testsuite/g++.dg/ext/attrib38.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code
  2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
                   ` (8 preceding siblings ...)
  2010-04-14 20:18 ` jason at gcc dot gnu dot org
@ 2010-05-04 19:10 ` jason at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-04 19:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2010-05-04 19:10 -------
Fixed for 4.6 (but see bug 43758).


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |43758
              nThis|                            |
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2010-05-04 19:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 23:43 [Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N))) sebor at roguewave dot com
2008-06-24 23:48 ` [Bug c++/36625] " pinskia at gcc dot gnu dot org
2008-06-24 23:49 ` pinskia at gcc dot gnu dot org
2008-06-26 20:47 ` [Bug c++/36625] bogus error on __attribute__((aligned(N))) in template code sebor at roguewave dot com
2008-12-27  7:06 ` pinskia at gcc dot gnu dot org
2009-12-26 18:31 ` paolo dot carlini at oracle dot com
2009-12-26 19:13 ` paolo dot carlini at oracle dot com
2010-01-19 23:30 ` jason at gcc dot gnu dot org
2010-01-20  5:51 ` jason at gcc dot gnu dot org
2010-04-14 20:18 ` jason at gcc dot gnu dot org
2010-05-04 19:10 ` jason 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).