test.cc:

#include <stdio.h>

template<typename T>
struct s {
        s() {
                printf("Print me, please!\n");
        }
};

int main(){
        s<int> x;
        unsigned s<int> y;
}


% g++ -Wall test.cc -o test &&./test
test.cc: In function 'int main()':
test.cc:12: warning: unused variable 'y'
Print me, please!


First of all, I find it surprising that this even compiles. Secondly, the
"unsigned s<int>" is treated as "unsigned int" (note that "Print me, please!"
is only printed once).


-- 
           Summary: Unsigned templatized struct treated as unsigned int
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stonebone at planetunreal dot com


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

Reply via email to