Skip to content

IRAM_ATTR ignored for templated function (IDFGH-2429) #4542

@BlueAndi

Description

@BlueAndi

Environment

  • Development Kit: [ESP32-DevKitC]
  • Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]
  • Module or chip used: [ESP32]
  • IDF version: v3.2.3-105-g65db2bf87
  • Build System: [PlatformIO]
  • Compiler version: 1.22.0-80-g6c4433a5
  • Operating System: [Windows]
  • Power Supply: [external 5V]

Problem Description

IRAM_ATTR is ignored for templated function, like
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435

Expected Behavior

IRAM_ATTR is considered.

Code to reproduce this issue

#include <Arduino.h>

template <typename Type>
class TestClass
{
public:
    TestClass(Type value) :
        m_value(value)
    {
    }

    Type m_value;
    
    Type IRAM_ATTR add(Type value) const _NOINLINE
    {
        return m_value + value;
    }
};

static TestClass<int> myTest(5);

void setup()
{
}

void loop()
{
    Serial.println(myTest.add(random(10)));
}

Debug Logs

Check via xtensa-esp32-elf-nm.exe

...
400e8710 W TestClass<int>::add(int) const
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions