-3

This bug makes absolutely no sense because there are seemingly unlimited places where you can comment out or uncomment a section and it goes away. The error given is:

error: definition with same mangled name '_ZN6jeaiiiL6digitsE' as another definition

A minimal example is given here on Godbolt. And here as a repo you can download.

On my computer I am using Clang version 22.0.0, but the Godbolt version is 21.1.0 and the same thing happens.

The source looks something like this:

main.cpp:

#include "./StringClass.h"
#include <exception>

import glm_module; // MOVING THE IMPORT HIGHER BEFORE THE INCLUDE MAKES IT COMPILE



struct Foo {
    unsigned int member; // MAKING THIS TYPE INT INSTEAD OF UNSIGNED INT MAKES IT COMPILE
};



void selectPhysicalDevice()
{
    //std::terminate(); // UNCOMMENTING THIS MAKES IT COMPILE


    Foo foo{};
    auto max_samplers = foo.member;

    String str;
    str.append(max_samplers); // COMMENTING THIS OUT MAKES IT COMPILE
    // REPLACING max_samplers WITH AN INTEGER LITERAL, ie., 1, MAKES IT COMPILE


    String str2;
    str2.append(1); // COMMENTING THIS OUT MAKES IT COMPILE

}





int main()
{


}

As you can see it makes absolutely no sense. I tried to compile this on a new version of MSVC and it compiles fine. It's interesting the error goes away when doing import BEFORE the includes on Clang, because I was told on GCC it's the other way around, the imports need to come AFTER the includes.

12
  • auto max_samplers = foo.member; Why are you using foo.member without initialization? Commented 12 hours ago
  • @BenSzekely It's initialised as far as I understand. I initialised it with {}, but that's not really the point, the whole thing is an example meant to provoke the error so I know what's happening. Commented 12 hours ago
  • I cloned the repository, and am trying to compile it now. I'll see what I can find... Commented 12 hours ago
  • 5
    The repro needs to be in the question itself, not relying on external links. And to do that, you should make the example minimal. Your Compiler Explorer link uses 236 lines (215 if we don't count the trailing blank lines). Applying basic minimalizing techniques (and recognizing that the type of 1 is int), that goes down to 78 lines,making it easier to see what is relevant. ("Basic" meaning I did not attempt to debug, just simplify.) Commented 9 hours ago
  • 1
    A useful trick when reducing to a minimal reproducible example is to take a break then come back to it, especially if it seems like you've reduced a lot. (I suspect that there was a significant reduction before this question was posted, just not enough.) Speaking of which: 43 lines and only 3 files Commented 5 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.