[Bug c++/36625] New: missing diagnostic on invalid __attribute__((aligned(N)))

sebor at roguewave dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 24 23:43:00 GMT 2008


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



More information about the Gcc-bugs mailing list