-1

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.

8
  • auto max_samplers = foo.member; Why are you using foo.member without initialization? Commented 2 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 2 hours ago
  • I cloned the repository, and am trying to compile it now. I'll see what I can find... Commented 2 hours ago
  • @BenSzekely OK. The repo comes with a CMakePresets.json for a Clang debug build and a default build which can be used with anything, like MSVC or even GCC I believe. Commented 2 hours ago
  • @Zebrafish You said commenting str.append(max_samplers); makes it compile but that is not the case on godbolt link. Also, commenting str2.append(1); also doesn't make it compile as opposed to your claim. Commented 2 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.