Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:11:44+00:00 2026-06-13T08:11:44+00:00

I am implementing the Merge sort algorithm. The problem is when I try to

  • 0

I am implementing the Merge sort algorithm. The problem is when I try to use a vector of automatically deduced types within the algorithm.

template <typename TIterator, typename TCompare>
void mergeSort(TIterator begin, TIterator end, TCompare criterium)
{
     //...
     auto help = *begin;                // help is a value (not a reference)
     QVector<decltype(help)> leftPart;  // now decltype(help) is also a value
     //...                              // and not a reference
}

This works.

But once I make the algorithm pass the TIterators by constant reference, I get an error which I never got in my whole life:

template <typename TIterator, typename TCompare>
void mergeSort(const TIterator& begin, const TIterator& end, TCompare criterium)
{
     //...
     auto help = *begin;                    // help is a value (not a reference)
     QVector<decltype(help)> leftPart;  // now decltype(help) is also a value
     //...
}

results in:

In function 'void mergeSort(const TIterator&, const TIterator&, TCompare)':
internal compiler error: in type_unification_real, at cp/pt.c:14176

I am using g++ 4.6.3 on Ubuntu

What went wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:11:45+00:00Added an answer on June 13, 2026 at 8:11 am

    An internal compiler error occurs whenever the compiler fails, which means that you found a bug. This is the reason while early adoption of new standards is usually called the bleeding edge: sometimes, it makes you bleed 😉

    There might be something wrong with your code, or there might not. It’s not possible to tell from this output alone. What is certain is that the compiler does not support it so you might want to change it instead.

    In particular, lookup std::iterator_traits<> to see all the things you can deduce from an iterator’s type:

    typename std::iterator_traits<TIterator>::value_type help = *begin;
                                         // ::reference
                                         // ::pointer
                                         // ...
    

    By circumventing the automatic deduction, you will probably be able to get past the compiler bug.


    Note: if you wish to report the bug, which is certainly laudable, you will be asked to produce a preprocessed file reproducing the issue. This file should be as small as possible. It can be generated using -E on the gcc command line and generally ends up with the .ii extension.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an unusual problem. I've been implementing Merge Sort and have encountered the
I am implementing a version of merge sort in c. For the first step
While implementing this generic merge sort , as a kind of Code Kata ,
I was going over the 2 way merge sort algorithm and was thinking if
I am writing a c++ program implementing the Merge Sort iteratively. The main code
As a learning excercise, I've just had an attempt at implementing my own 'merge
when implementing a recursive function during development, i will use a counter and exit
I am implementing a display algorithm where we can have multiple layers of windows
I have studied the theory of the merge sort but don't have any idea
I'm implementing a bitonic sort using intel TBB. When using the parallel_invoke method all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.