Are compilers safe?

I've been wondering how compilers like GCC compile after each release, but that made me think:
Are compilers safe?

Correct me if I'm wrong, but even if one version of the compiler with some malicious code was compiled in one step along the way, it would not be infected after that? This would trigger a chain reaction and possibly infect millions of devices.

Has that happened already? If so, how did we find that out?
Is there a group or organization that makes sure that does not happen?

compilers – Syntax-driven translation scheme for Postfix to Infix notation

I read Compiler principles, techniques and tools Textbook and I have encountered a problem from Exercise 2.3

We need to construct a syntax-driven translation scheme that translates the arithmetic expression from the postfix notation to the infix notation. I constructed a scheme as follows.

expr -> expr expr + | expr expr - | expr expr * | expr expr / | digit


expr -> expr {print('+')} expr +
      | expr {print('-')} expr -
      | {print('(')} expr {print(') * (')} expr {print(')')} *
      | {print('(')} expr {print(') / (')} expr {print(')')} /
      | digit {print(digit)}

The translation seems pretty valid, but I can not figure out how to create an analysis tree with this translation.

Can someone explain to me how to construct a parser tree? 2 3 + 3 5 3 * - * and 9 5 2 * -? Thank you in advance!

Assembler – compilers of high-level languages ​​always compile them directly to machine code?

As an amateur bash / javascript scripter who never wrote a sentence in assembly, I ask:

Do high-level compilers always compile them directly into machine code, or are there cases where a high-level compiler compiles them into assembler (and assembler then compiles input into machine code output)?

Are C # compilers optimizing the facade pattern?

If I hide the implementation behind a facade or the "pimpl" pattern in C #, does the compiler optimize the intermediate function call if it only calls an equivalent method from another class with the same parameters?

This is the case for dynamically created classes.

For example:

class A
    internal bool Process(float value)
        if (value > 0.5f)
            return true;
        return false;
class B
    private A m_A = new A();
    internal bool Process(float value)
        return m_A.Process(value);

Perhaps the compiler can replace calls from B.Process with A.Process.

Ignore the contents of the classes. They are too simplistic to give a brief example.

Why do we learn compilers? – Computer Science Stack Exchange

Let me break down some possible interpretations of your question:

What is the purpose of learning compilation?

There are several possible answers:

  1. This should be required so that you know how to create a compiler. This is not a good answer these days.
  2. Part of the goal of the computer science curriculum is to explain how a computer works, paying attention to the hardware. This includes the operating system, file systems, the compiler, the network stack and much more.
  3. As a programmer, you use compilers. Sometimes it helps to know what happens under the hood. For example, if you understand garbage collection, you can more easily choose which language to use in embedded applications.
  4. The compilation is part of the standard curriculum, so you may be asked about it in interviews.

Why are you teaching me to compile?

Apart from the reasons mentioned above, there is another one: the universities are very conservative. In the past, it has become increasingly important to understand how compilers work. This is less important these days, but change is slow, material
that made sense 10 years ago and is still taught today.

That means some universities could reform their compilation curriculum, for example, by reducing parsing, focusing on more exciting aspects such as optimization, memory management, dynamic and static analysis, and the like.

Why do I study compilation?

As a prospective programmer, your university education includes many seemingly useless classes, such as calculus. People go to university for a variety of reasons – it's a rite of passage, an opportunity for socializing and dating, and it can help you find a job. or just family or peer pressure.

Some people refrain from university education, prefer another formal education or even self-education. Some of these people are very successful.
For some reason you opted for the university and not for one of these alternative routes. They should accept that university education is more theoretical and try to make the most of it.

Will C ++ Header Only will support the future direction of the C ++ programming style with the supporting compilers / tools in the near future

Writing C ++ code with just a header is more convenient, but it is not efficient if the program needs to be continually recompiled. Is it possible in the future that C ++ will be fully optimized in this type of programming? This will be very helpful for new programmers in C ++ and avoid the complex compilation process. – How is MsBuild related to the compilers vbc.exe and csc.exe in Visual Basic or C #?

These are the concepts that I have just read on the internet:

VBC.EXE is the Visual Basic Compiler.
CSC.EXE is the C # compiler

MsBuild is the compiler that uses Visual Studio to translate Visual Basic and C # into intermediate code.

I do not understand how these terms are related.