When you spend a full day tracking down a bug :-( Bug in SDCC 4.0?

Pagina 4/4
1 | 2 | 3 |

Van PingPong

Prophet (3768)

afbeelding van PingPong

03-09-2020, 21:04

Bengalack wrote:
pgimeno wrote:

the syntax 3[p], only the syntax p[3]

Really. I was not aware of that syntax. I have never seen it before (in any language). What is it called? And is it part of a certain version of the standard?

this horrible thing is unfortunately part of the std specs.

Van salutte

Master (137)

afbeelding van salutte

03-09-2020, 22:15

I think that defining a[b] as *(a+b) is brilliant, and helps define in a simple way the expected behavior of the [] operator on all practical range of types for a and b with little room for unexpected behavior.

On the other hand, the [] operator in C++ can have non-intuitive behavior in corner cases which sometimes backfires, like addressing std::map elements using [] is only doable on non-const containers because [] may add new elements.

My particular weird use of the [] that I enjoy is "0123456789ABCDEF"[n], which is useful for fast decimal to hex conversions.

Van pgimeno

Champion (300)

afbeelding van pgimeno

03-09-2020, 22:24

salutte wrote:

I just tried sdcc 3.8 and it supports the 3[p] syntax for me without a problem. Is there any known failure case?

I have 3.5.0, maybe it was fixed later. Thanks!

Pagina 4/4
1 | 2 | 3 |