This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79819] collect2 undefined reference when -O0. Regression (or bugfix?) since gcc5


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79819

--- Comment #2 from Nikolay Bogoychev <nheart at gmail dot com> ---
> This attachment is a pain, is there really a need for each loader_file.ii to
> be in its own tar file?

No, there isn't really. I didn't realize I could only attach one file so I
merged everything.

> Also we can't debug a linker error with only a single file, even with four
> copies of the file.
>  

What would you need me to provide? I was under the impression that the
difference is in the generated code? Your website doesn't post what you need to
attach for linker errors.

> 
> This sounds like a bug in your code.
> 
> If you "odr-use" a function then it needs to be defined, even if it can
> never be reached at run-time e.g.
> 
> const bool x = false;
> void foo();
> int main() {
>   if (x)
>     foo();
> }
> 
> This requires a definition of void foo() even though it will never be
> called. Under certain conditions you don't get an error, such as when the
> compiler optimises away the call completely. But the rules of the language
> still say the definition is needed.

Thank you, I was asking for that. So I am to assume that whether it compiles or
not is abusing undefined behavior in GCC and the different behavior between
different versions shouldn't be considered a bug?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]