Bug 47329 - cc1plus segfaults when using variadic function template
Summary: cc1plus segfaults when using variadic function template
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.5
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-17 15:51 UTC by gmaizel
Modified: 2011-01-18 10:25 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gmaizel 2011-01-17 15:51:17 UTC
g++ reports segfault in cc1plus when attempting to compile code sample provided below:

$ g++ -std=c++0x -o test test.cpp

g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.

$ g++ --version

g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



------ test.cpp -----------------------

# include <iostream>
# include <vector>

void print(const std::vector<int>& pack)
{
    for(size_t i=0; i<pack.size(); i++)
        std::cout << pack[i] << " ";
    std::cout << "\n";
}

template<typename ...Vals> 
void print(std::vector<int>& pack, int v1, Vals... vals)
{
    pack.push_back(v1);
    print(pack, vals...);
}

template<typename ...Vals> 
void print(Vals... vals)
{
    std::vector<int> pack;
    print(pack, vals...);
}


int main()
{
    print(1);
    print("a"); // <-- this line triggers the failure
    print(2, 3, 4, 5);
    print(6, 7);
}
Comment 1 Jonathan Wakely 2011-01-18 10:25:08 UTC
I can't reproduce an ICE with FSF 4.4.3, 4.4.5, or 4.5/4.6 from svn, instead I get a diagnostic as expected because the code is invalid.

Maybe you are hitting a bug in the Ubuntu package, in which case it should be reported to Ubuntu