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

صفحة 4/4
1 | 2 | 3 |

بواسطة PingPong

Prophet (3680)

صورة 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.

بواسطة salutte

Master (132)

صورة 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.

بواسطة pgimeno

Champion (285)

صورة 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!

صفحة 4/4
1 | 2 | 3 |